Hello,
We are using the 1.0.2004.2 version of the LLBLGen Pro, and I'm evaluating Firebird 1.5 to replace our SqlServer (DataEngine version). We want to migrate our LLBL application to Firebird.
Everything seems to work OK except autogenerated keys (identity). And we use a lot of them having an Identity Primary Key in almost every table of our DataBase.
Firebird documentation suggests using triggers and generators to assign new values but LLBLGen has problems refetching these new values.
This code that works fine with SqlServer, using Firebird with tirggers and generators throws an exception.
DataAccessAdapter adapter = new DataAccessAdapter();
DetailEntity detail = new InternalUserEntity();
detail.Text = "something";
adapter.SaveEntity(detail, true);
adapter.Dispose();
int detailId = detail.Id;
The error occurs in the adapter.SaveEntity line.
Later we found that you don't encourage using triggers at all .
Posted on: 13-okt-2004 20:29:54
I've added a note to the section where the PK sequencing is mentioned and I've explained that triggers, default constraints and newid constructs will not make the value be read back It was indeed somewhat confusing. For example on Firebird, it's common practise to use a trigger to insert a sequence value, which will cause wrong results, as the PK value is always 1 higher than the value initially inserted due to the trigger (so the entity will never be read back )
The other option according to Firebird doccumentation is to use a stored procedure to retrieve a new value from a generator before saving the entity. Ussing this option would force us to change all our code.
Is there some other way of doing this that would allow us to migrate without forcing us to do a major code restructure?
Thanks.