-->
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.  [ 4 posts ] 
Author Message
 Post subject: JBoss MBean Service Transactions
PostPosted: Fri May 28, 2004 7:54 am 
Newbie

Joined: Fri May 28, 2004 6:11 am
Posts: 9
Hello,

I'am using Hibernate Version 2.1 with JBoss 3.2.3 as MBean service. In a 3 Tier application I want to use CMT Stateless-Session-Beans as facade for the Hibernate persistencelayer. This works so far, but I'am not sure if I'am using the MBean Service correctly.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>

<!-- Generated file - Do not edit! -->

<server>
   <mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=Hibernate">
       <depends>jboss.jca:service=RARDeployer</depends>
       <depends>jboss.jca:service=LocalTxCM,name=MySQLDS</depends>
       <attribute name="MapResources">de/fh_brs/inf/helpdesk/business/hibernate/EditorHibernate.hbm.xml,de/fh_brs/inf/helpdesk/business/hibernate/TroubleTicketHibernate.hbm.xml</attribute>
       <attribute name="JndiName">hibernate</attribute>
       <attribute name="Datasource">java:/MySQLDS</attribute>
       <attribute name="Dialect">net.sf.hibernate.dialect.MySQLDialect</attribute>
       <attribute name="UseOuterJoin">false</attribute>
       <attribute name="ShowSql">false</attribute>
       <attribute name="UserTransactionName">UserTransaction</attribute>
       <attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
       <attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
       <attribute name="CacheProvider">net.sf.ehcache.hibernate.Provider</attribute>
   </mbean>

</server>



Code:
/**
* @ejb.bean
*        display-name="EditorHibernateFacade"
*      jndi-name="ejb/EditorHibernateFacade"
*      name="EditorHibernateFacade"
*      type="Stateless"
*      view-type="remote"
*
* @ejb.transaction
*       type = "Required"
*
* @ejb.util
*       generate = "physical"
*/
public abstract class EditorHibernateFacadeBean implements SessionBean {
   
   /**
    * @ejb.interface-method
    */
   public Editor create(String name) throws NamingException, HibernateException {
      InitialContext context = new InitialContext();
      Object obj =  context.lookup("hibernate");
      SessionFactory factory = (SessionFactory) obj;
      Session session = factory.openSession();
      Transaction trans = session.beginTransaction();
      EditorHibernate editor = new EditorHibernate();
      editor.setName(name);
      session.save(editor);
      trans.commit();
      session.close();
      return editor;
   }
}



My Question is, if I need to create the Hibernate transaction or if it is implicit created in the session because I'am using CMT.

Thank you!

Alexander Kirsch


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 28, 2004 7:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If you are using CMT, you can leave out all Hibernate Transaction API code. You must however explicitly flush() the session.


Top
 Profile  
 
 Post subject: Transaction API
PostPosted: Tue Jun 08, 2004 3:29 pm 
Regular
Regular

Joined: Tue Dec 09, 2003 2:39 pm
Posts: 106
Location: Toronto, Canada
For our application we re-use our DAO layer in CMT and non-CMT environments.

Is it in-appropriate to leave the Transaction API code in our DAO? What would be the effect of leaving this code in a CMT environment?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 08, 2004 5:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No problem leaving the transaction API code in in a CMT environment. The Transaction API will just use the existing JTA transaction.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.