aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate does not fill one-to-many after an insert and a select in the same transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate does not fill one-to-many after an insert and a select in the same transaction" Watch "Hibernate does not fill one-to-many after an insert and a select in the same transaction" New topic
Author

Hibernate does not fill one-to-many after an insert and a select in the same transaction

Tony David
Greenhorn

Joined: Mar 19, 2012
Posts: 15
Hi everyone,

I have a simple relationship case between 2 objects :
Process <- Operation



I try to insert an operation and then getting the process with all its operations, I do that in the same transaction.
It's not a good design because it involve dirty data, but it's useful for testing.

To do that :



I get all my process object in my returned list but the one-to-many for Operations is not filled (I don't get an exception but it's empty).
In logs I can see the request with the join between Process and operation but the Operation collection is not filled in Process.

I tried with HQL and criterias with exactly the same result.
If I commit the transaction after the insertion then call the select, it works, the operation collections is filled in Process entities.

I tried directly in the RDBMS with a transaction, with the same way an insert then call a select, new inserted lines are returned before the transaction rollback.

So I don't understand why Hibernate does not fill my operation collection, if someone
wan explain me this odd behavior, it would be helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate does not fill one-to-many after an insert and a select in the same transaction
 
Similar Threads
retrieving object hierarchy - many-to-one?
EJBQL distinct question
Concurrency issue for dimensional tables
Hibernate Transaction Autocommit set to false
Hibernate Newbie