java - nested EJB not rolling back -


simple application service throws exception:

@stateless public class appservice {      @inject     private repository repo;     @inject     private appservice2 service2;      public void createfoo(string name) {         foo foo = new foo(repo.nextidentity(), name);         repo.save(foo);     //    service2.createbar(name);         throw new runtimeexception("asdf");     } } 

repository @stateless , appservice2 similiar appservice.

when throw exception above foo rolled - ok. when call service (the commented), bar not persisted db foo persisted.

why foo not rolled after calling service?

edit

i found appservice2 making checking query db before saving bar

public void createbar(string name) {     if (repo.find(name) != null)         ...     bar bar = new bar(repo.nextidentity(), name);     repo.save(bar); } 

and query interrupting transaction. when set @transactionattribute on method

@transactionattribute(transactionattributetype.not_supported) public bar find(string name) {} 

it resolves problem.

could explain how works?

is right way or there another?


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -