Problems saving sub-types to database

Posts   
 
    
olav78
User
Posts: 8
Joined: 14-Jun-2007
# Posted on: 05-Jul-2007 22:13:10   

Template: adapter.

Hi,

We have a hierarchy with CargoOperation as a super-type and Loading and Discharging as sub-types of CargoOperation. The inheritance type is Target per Entity. We create some new Loading entities and some new discharging entities. The problem occurs when we try to save the entities:


foreach (DischargingEntity dischargingEntity in dischargings)
 {
    adapter.SaveEntity(dischargingEntity,false,true);
 }

Or just:


adapter.SaveEntityCollection(dischargings, false, true);

This works. But then we try to save the Loading entities the same way and we get this error:

“An exception was caught during the execution of an action query: Violation of UNIQUE KEY constraint 'IX_cargo_operation'. Cannot insert duplicate key in object 'dbo.cargo_operation'.”

Ok. When we do it the opposite way (create entities of booth types, and save the Loading entities first and Discharging entities last), the same error now occurs for the Discharging entities.

I have no clue what the problem is. Anyone who can help?

Ps: A lot of the fields for the different entities are the same for all the CargoOperations we inserts – booth the Loading and the Discharging entities - (especially the foreign keys to other tables like Cargo, Fixture etc…).

Ps2: The entities are transformed to xml and then transformed back to objects before they are inserted in the database.

  • Olav
Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 06-Jul-2007 11:01:27   

1- Please post the LLBLGen Pro runtime libraries version that you are using. 2- Post the database structure, for those 3 tables. 3- Post the generated insert queries (ref: manual ""Generated code - Troubleshooting and debugging) 4- Post a simplified code snippet about how those entities are created and filled out, before being saved.

Thanks.

olav78
User
Posts: 8
Joined: 14-Jun-2007
# Posted on: 06-Jul-2007 20:07:42   

Oops, it was not a llblgen problem ( it was a database problem)flushed . Sorry.