Dear jboss-users

I need to use declarative transactions in my project.

Unfortunately I cannot manage to have my transactions

rolled back when there's an error. So this is

my scenario:

I have a Session bean Stateless with attribute:

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

And 2 Entity beans with attributes:

<persistence-type>Container</persistence-type>

<trans-attribute>Required</trans-attribute>

<persistence-type>Container</persistence-type>

<trans-attribute>Required</trans-attribute>

Now inside the session bean there's a method

that calls the Entity bean create method

void doMusic() {

CD c = (CD)homeCd.create(50);

c.setTitle("Title1");

c.setArtist("Artist1");

Tape t = (Tape)homeTape.create(100);

c.setTitle("Title2");

c.setArtist("Artist2");

}

Now this is the matter- if the second bean (in this case Tape)

fails (because of duplicate Primary Key) then the first create

is NOT rolled back!!! When I issue a ?select? of the CD table

the row is added.

Why it happens so ? I want that both "create" share the same

transaction so I set up tx-Required in both of them.

A last note: I'm using PostgreSql as DB.

I'd be very very grateful if someone gives me an advice.

Thank you very much

Francesco

 

Reply via email to