Hibernation is maintained

I have a question about how Hibernate saves an entity. Let them say that I have an entity A that is related to an object B, and the other to an entity C. I create an instance of A and populate it with new instances of B and C. When I save A, I need C to be saved before B Is there a way to do this?

Many thanks.

+4
source share
1 answer

No, you cannot control the order.

The only thing you can do is to clear the session after the session after you have established the AC relation and then create the AB relation. A flash will cause hibernation to enter new data into the database, but will not commit transactions.

After a flash, the data may or may not be visible to other transactions depending on the database configuration (for example, there are 4 transaction modes in mysql: http://dev.mysql.com/doc/refman/5.0/en/set-transaction.html )

+1
source

Source: https://habr.com/ru/post/1304444/


All Articles