Hello all!
I�m getting the following error:
org.hibernate.exception.GenericJDBCException: could not insert: [Table4VO]
And this is the reason:
SEVERE: [Atinav][
JDBC SQL Server Driver:Ver C3.0C] Violation of PRIMARY KEY constraint 'PK'. Cannot insert duplicate key in object 'Table4'.
// ---------------------
MY CENARIO IS:
#1. My rellational mapping it�s like:
Table1VO (Major table whith many to one relationship for Table2VO where
cascade="save-update")
Table2VO (Table whith many to one relationship for Table3VO where
cascade="save-update")
Table3VO (Table whith one to one relationship (bi-direcional association)
for Table4VO where cascade="save-update")
Table4VO (Table whith one to one relationship for Table3VO where
cascade="none" and constrained="true"; the primary key
is a FK: PrimaryKey from Table3)
#2. For updating operation, all the objects instances for the rellational mapping above are duly instantiated. For example:
1 Table1VO has 1 Table2VO that has 1 Table3VO with 1 Table4VO (like in database....... that�s mean, a perfect update)
// ----------
WHAT I WANT it�s to include a new Table3VO object that will generate an insert not only on Table3 but in Table4 also (because the rellationship mentioned above).
// ----------
PROBLEM:
For the collection of Table3VO objects in Table2VO (many-to-one) object, the one that already exists on the database should be updated and the new instance should be inserted. THE SAME THING SHOULD HAPPEN FOR THE Table4!!! But the framework it�s trying to do an insert with the object that already exists on Table4 and that�s is throwing the exception off violation off primary key (even with the right instance of the Table4VO in the respective Table3VO obj.).
Does somebody know what is haaping? Or the reasons???
Thank�s for your attention.
PS: sorry for my bad english!!!