Hibernate does not fill one-to-many after an insert and a select in the same transaction
posted 4 years ago
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.