Monday, 15 August 2011

Hibernate members deletion not seen further within transaction -



Hibernate members deletion not seen further within transaction -

i'm using hibernate jta (container managed transactions).

let's have next model: employee many-to-one relations office , team. i've set bidirectional associations.

class employee{ office office; team team; } class office{ list<employee> employees; } class team{ list<employee> employees; }

now data:

emp 1 ofc 1 , team 1

emp 2 ofc 1 , team 2

the problem: iterate on team 1 employees (i.e. emp 1) , delete them. within same transaction execute hql select ofc 1. within ofc 1 employees list expect find emp 2 (since emp 1 has been deleted on previous step) result both employees still there.

i tried flushing entity manager after deletion: same thing.

as required jpa standard, hibernate unschedule removal if persist operation applied/cascaded removed entity.

make sure remove references deleted entity other managed entity instances.

hibernate transactions jta

No comments:

Post a Comment