-->
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.  [ 3 posts ] 
Author Message
 Post subject: CMTTransactionFactory: transactions not committed
PostPosted: Fri May 13, 2005 5:19 pm 
Newbie

Joined: Sun Feb 06, 2005 11:46 am
Posts: 4
Location: Rotterdam, Netherlands
I'm lost, I can't get working what seems to be very easy.

I want Hibernate to hook on to the transaction of a CMT stateless session bean. I set transactions to RequiresNew, like:
Code:
<ejb-jar>

   <description>Verlanglijstje</description>
   <display-name>Verlanglijstje</display-name>

   <enterprise-beans>
   
      <session id="Verlanglijstje">
         <display-name>Verlanglijstje</display-name>
         <ejb-name>Verlanglijstje</ejb-name>
         <home>nl.kransen.verlanglijstje.service.VerlanglijstjeServiceHome</home>
         <remote>nl.kransen.verlanglijstje.service.VerlanglijstjeService</remote>
         <ejb-class>nl.kransen.verlanglijstje.service.VerlanglijstjeServiceEJB</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>
      </session>
   
   </enterprise-beans>
   
   <assembly-descriptor>
      <container-transaction>
         <description></description>
         <method>
            <ejb-name>Verlanglijstje</ejb-name>
            <method-name>*</method-name>
         </method>
         <trans-attribute>RequiresNew</trans-attribute>
      </container-transaction>
   </assembly-descriptor>

</ejb-jar>


So all methods get a fresh CMT transaction.

I have the following hibernate propeties:
Code:
hibernate.session_factory_name = java:comp/env/hibernate/SessionFactory
hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql = false
      
hibernate.connection.provider_class = org.hibernate.connection.C3P0ConnectionProvider
hibernate.connection.driver_class = org.postgresql.Driver
hibernate.connection.url = jdbc:postgresql://localhost:5432/jboss
hibernate.connection.username = jboss
hibernate.connection.password = jboss

hibernate.c3p0.min_size = 5
hibernate.c3p0.max_size = 20
hibernate.c3p0.timeout = 1800
hibernate.c3p0.max_statements = 50

hibernate.cache.provider_class = org.hibernate.cache.EhCacheProvider
hibernate.cache.use_minimal_puts = false

# transactions
hibernate.transaction.factory_class = org.hibernate.transaction.CMTTransactionFactory
hibernate.transaction.manager_lookup_class = org.hibernate.transaction.JBossTransactionManagerLookup
hibernate.transaction.flush_before_completion = true
hibernate.transaction.release_mode = auto
hibernate.transaction.auto_close_session = true


I think I did everything that was described in any documentation on this that I found.
In my bean, I use something like (shortened):
Code:
      Session session =
      new Configuration()
      .configure()
      .addClass(Gebruiker.class)
      .addClass(Wens.class)
      .buildSessionFactory().getCurrentSession();
      session.save(someobject);


In the logging, I can see a org.hibernate.SQL log, which mentions an INSERT of the object, but it is not propagated to the database. I tried surrounding Transaction demarcation code or flush/close the Session (though neither should be necessary). What am I missing? I am using JBoss 4.0.1, PostgreSQL 8.0.2, Hibernate 3.0.2. I assumed that the transaction in a CMT is committed when using a RequiresNew after a method returns, is that right? Or should I mark somewhere to commit every method call?

I am totally lost, hope that someone can help me.


Top
 Profile  
 
 Post subject: I got it
PostPosted: Sun May 15, 2005 6:31 am 
Newbie

Joined: Sun Feb 06, 2005 11:46 am
Posts: 4
Location: Rotterdam, Netherlands
It turns out that in order to use CMT, you are forced to use a DataSource supplied by the AS (JBoss in my case). I let Hibernate create a C3P0 datasource before, and when I changed that to a JBoss supplied datasource, it started working. Maybe that's obvious, but at least for me it wasn't. Might be worth documenting.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 16, 2005 7:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is a regular J2EE feature.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.