SaveEntity fails on Oracle when refetchAfterSave set to true

Posts   
 
    
rich
User
Posts: 22
Joined: 09-Sep-2004
# Posted on: 12-Jan-2005 12:18:31   

Hi,

I've seen a couple of postings related to this but neither helped me. My situation is fairly simple - I'm calling SaveEntity but it's failing with "During a recursive save action an entity's save action failed. The entity which failed is enclosed."

This is code which works against an SQL Server database but is now pointed at Oracle. I have verified that I can do the equivalent insert statement in SQL*Plus and the row adds so the trigger and sequence are working properly.

Setting refetchAfterSave to false gets me past the error but obviously that's not a solution.

I know this must relate to how it is trying to get the identity of the new row but I'm not sure where to look next. Your help would be appreciated.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-Jan-2005 12:48:41   

Please check if you have set the PK fields of each entity to a sequence in the designer and re-generated the code. Otherwise there is no sequence defined for a field and LLBLGen Pro will not generate SQL to retrieve the sequence value which makes the PK field become 0 and a refetch obviously fails, terminating the recursive save.

Also, don't set PK values using triggers, as LLBLGen Pro can't read back the sequence value inserted in the row as the sequence value is read before the row is written and passed in as a normal value for the PK field.

Frans Bouma | Lead developer LLBLGen Pro
rich
User
Posts: 22
Joined: 09-Sep-2004
# Posted on: 12-Jan-2005 15:43:02   

Thanks Otis, the trigger/sequence stuff is the cause. I can probably get rid of it for this particular set of tables as luckily they are only accessed by LLBLGen code. Other tables we may need to add to later are accessed and added to by legacy code though and it relies on sequence numbering being handled by the database. Yikes.

I assume setting the designer attribute tells LLBLGen to generate code that does all the sequencing? Is your recommendation that all sequencing of primary keys is done in this way rather than with database functionality?

It must be one of those days because getting past this problem I walk straight into another.... I'll start a different thread as it's completely unrelated.