Hi All,
I have a table(SemiFlatTo) which has two children(Child1To and Child2To). And they are related by column which is generated by sequence "VAE_SEQ".
My requirement is to do cascade save of all three tables. well everuthing works fine now.
But lately I got another requirement, in which I have to save collection of SemiFlatTo's as batch update. In this case, insert is successful only if all the SemiFlatTo's are inserted, even if one fails, all the other SemiFlatTo's will be rolled back. In this condition, I have to traverse each of the SemiFlatTo's individually and do a insert.
Now when th batch insert fails and when I want to insert one by one, hibernate generates update statements for children instead of insert stm. The log below clearly shows all the steps. Can you please tell me why hibernate is generating update stm instead of insert statement for children.
Thank You in advance
[Apr 05, 2006 08:59:46] DEBUG [DriverManagerConnectionProvider] - total checked-out connections: 0
[Apr 05, 2006 08:59:46] DEBUG [DriverManagerConnectionProvider] - using pooled JDBC connection, pool size: 0
[Apr 05, 2006 08:59:46] DEBUG [JDBCTransaction] - begin
[Apr 05, 2006 08:59:46] DEBUG [JDBCTransaction] - current autocommit status:false
[Apr 05, 2006 08:59:46] DEBUG [BatcherImpl] - about to open: 0 open PreparedStatements, 0 open ResultSets
[Apr 05, 2006 08:59:46] DEBUG [BatcherImpl] - values nextval for VAE_SEQ
Hibenate: values nextval for VAE_SEQ
[Apr 05, 2006 08:59:46] DEBUG [BatcherImpl] - preparing statement
[Apr 05, 2006 08:59:46] DEBUG [SequenceGenerator] - Sequence identifier generated: 256
[Apr 05, 2006 08:59:46] DEBUG [BatcherImpl] - done closing: 0 open PreparedStatements, 0 open ResultSets
[Apr 05, 2006 08:59:46] DEBUG [BatcherImpl] - closing statement
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - generated identifier: 256
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - saving [com.abc.def.SemiFlatTo#256]
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - processing cascades for: com.abc.def.SemiFlatTo
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - done processing cascades for: com.abc.def.SemiFlatTo
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - processing cascades for: com.abc.def.SemiFlatTo
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - cascading to collection: com.abc.def.SemiFlatTo.child1
[Apr 05, 2006 08:59:46] DEBUG [Cascades$4] - cascading to saveOrUpdate()
[Apr 05, 2006 08:59:46] DEBUG [Cascades$15] - id unsaved-value strategy NULL
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - saveOrUpdate() previously saved instance with id: 87
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - updating [com.abc.def.Child1To#87]
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - cascading to collection: com.abc.def.SemiFlatTo.child2
[Apr 05, 2006 08:59:46] DEBUG [Cascades$4] - cascading to saveOrUpdate()
[Apr 05, 2006 08:59:46] DEBUG [Cascades$16] - version unsaved-value strategy NULL
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - saveOrUpdate() unsaved instance
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - running Session.finalize()
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - generated identifier: com.abc.def.Child2To@5102ff[idMfAcctgRslt=256,cdRateType=FAS]
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - saving [com.abc.def.Child2To#com.abc.def.Child2Key@5102ff[idMfAcctgRslt=256,cdRateType=FAS]]
[Apr 05, 2006 08:59:46] DEBUG [Versioning] - Seeding: 2006-04-05 08:59:46.976
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - done processing cascades for: com.abc.def.SemiFlatTo
[Apr 05, 2006 08:59:46] DEBUG [JDBCTransaction] - commit
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - flushing session
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - processing cascades for: com.abc.def.SemiFlatTo
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - cascading to collection: com.abc.def.SemiFlatTo.child1
[Apr 05, 2006 08:59:46] DEBUG [Cascades$4] - cascading to saveOrUpdate()
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - saveOrUpdate() persistent instance
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - cascading to collection: com.abc.def.Child2To [Apr 05, 2006 08:59:46] DEBUG [Cascades$4] - cascading to saveOrUpdate()
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - saveOrUpdate() persistent instance
[Apr 05, 2006 08:59:46] DEBUG [Cascades] - done processing cascades for: com.abc.def.SemiFlatTo
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - Flushing entities and processing referenced collections
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - Collection found: [com.abc.def.SemiFlatTo.child1#256], was: [<unreferenced>]
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - Collection found: [com.abc.def..SemiFlatTo.child2To#256], was: [<unreferenced>]
[Apr 05, 2006 08:59:46] DEBUG [SessionImpl] - Updating entity: [com.abc.def.Child1To#87]
[Apr 05, 2006 08:59:46] DEBUG [JDBCTransaction] - rollback
[Apr 05, 2006 08:59:47] DEBUG [SessionImpl] - transaction completion
[Apr 05, 2006 08:59:47] ERROR [HibernatePersistenceManager] - Exception occured in insert To
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: