-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate3/JBoss4 JTA rollback not performed
PostPosted: Thu Jun 23, 2005 11:24 am 
Newbie

Joined: Thu Jun 23, 2005 11:16 am
Posts: 1
Hi,

I am using Hibernate inside the JBoss server. Referring to the Documentation, the following fragment of code (inside a Stateless Beans)
should use the JTA without having code to deal with transactions. The method uses "RequiresNew".
I was expecting hibernate not to store the dataset into the DB, but
the user has been made persistent, although the Transaction is marked as "rollback".
Furthermore, debugging the application, I could see that the INSERT statement was send to the DB after session.save( user ); has been invoked
and NOT after the completion of the transaction.

Any Thoughts?

Code:
public User createUser(String firstname, String lastname) throws Exception {
   Context ctx = new InitialContext();
     SessionFactory sf = (SessionFactory)
           ctx.lookup( "java:/hb/SessionFactory" );
        Session session = sf.getCurrentSession();
       User user = new User();
user.setFirstname(firstname);
   user.setLastname(lastname);
     session.save(user);
     
        this.ctx.setRollbackOnly();
     return user;
    }

Debug message from the JBoss server:
Code:
[STDOUT] Hibernate: insert into User_hbm_tbl (firstname_col, lastname_col) values (?, ?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 23, 2005 11:37 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why are you mixing CMT and BMT?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.