Hibernate EM: 3.3.0.GA
Hi all,
I would like to know where can I find more information about persistence context and suspended transactions.
I'm getting some weird results when using requires new (suspend the current transaction and creates a new one) where I have the same entity changed in different transactions.
Eg.
Code:
main()
{
// create new transaction
Entity entity = new Entity();
entitiManager.persist( entity );
changeStatus1( entity );
changeStatus2( entity );
// commit
}
changeStatus1( Entity entity )
{
// suspend and create one transaction
entity.setAttribute1( "abc" );
entityMaganer.merge( entity );
// commit
}
changeStatus2( Entity entity )
{
// suspend and create one transaction
entity.setAttribute2( "abc" );
entityMaganer.merge( entity );
// commit
}
Is this kind of thing currently supported? Specificaly I'm getting wrong result where I have a cascade relationship (merge, persist). The related entity get inserted multiple times in database.
Any help is appreciated. Thanks.