-->
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: Hibernate with CMT does no commit
PostPosted: Wed Oct 26, 2005 5:32 am 
Newbie

Joined: Tue Nov 30, 2004 10:39 am
Posts: 10
Hi,

I use the JBoss 4.0.1 EJB container with stateless session beans which call hibernate (3.0.x) to store the data.
I have a CMT trasaction that I use for hibernate CRUD operations. All operations work fine, but when the transaction ends at the session facade, the hibernate session is not committed.

AFAIK with CMT I dont have to commit the transaction myself, or close the connection. All these are done by the container.
If I use container managed entity beans, then all transactions are committed fine.

Does anybody know why my transactions are not committed when I use CMT with hibernate?

thanks, ALex.

Here is an output from the console, where we can see that the SQLCLI:SQLENDTRAN COMMIT is missing

Code:
11:19:37,578 INFO  [STDOUT] Hibernate: insert into TX (ACCOUNT_ID, TIME_STAMP, AMOUNT, BALANCE, DESCRIPTION, TX_ID) values (?, ?, ?, ?, ?, ?)
11:19:37,578 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLPREPARE insert into TX (ACCOUNT_ID, TIME_STAMP, AMOUNT, BALANCE, DESCRIPTION, TX_ID) values (?, ?, ?, ?, ?, ?)
11:19:37,578 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLEXECUTE:48
11:19:37,588 INFO  [STDOUT] Hibernate: insert into TX (ACCOUNT_ID, TIME_STAMP, AMOUNT, BALANCE, DESCRIPTION, TX_ID) values (?, ?, ?, ?, ?, ?)
11:19:37,588 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLEXECUTE:48
11:19:37,588 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLFREESTMT:48
11:19:37,588 INFO  [STDOUT] Hibernate: update ACCOUNT set TYPE=?, DESCRIPTION=?, BALANCE=?, CREDIT_LINE=?, BEGIN_BALANCE=?, BEGIN_BALANCE_TIME_STAMP=? where ACCOUNT_ID=?
11:19:37,588 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLPREPARE update ACCOUNT set TYPE=?, DESCRIPTION=?, BALANCE=?, CREDIT_LINE=?, BEGIN_BALANCE=?, BEGIN_BALANCE_TIME_STAMP=? where ACCOUNT_ID=?
11:19:37,588 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLEXECUTE:49
11:19:37,598 INFO  [STDOUT] Hibernate: update ACCOUNT set TYPE=?, DESCRIPTION=?, BALANCE=?, CREDIT_LINE=?, BEGIN_BALANCE=?, BEGIN_BALANCE_TIME_STAMP=? where ACCOUNT_ID=?
11:19:37,598 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLEXECUTE:49
11:19:37,598 INFO  [STDOUT] [Server@3680c1]: 5:SQLCLI:SQLFREESTMT:49




Here is my hibernate.cfg.xml
Code:
<hibernate-configuration>
  <session-factory name="java:hibernate/DukesBankSessionFactory">
    <property name="transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>
    <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
    <property name="transaction.flush_before_completion">true</property>
    <property name="transaction.auto_close_session">true</property>

    <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.url">jdbc:hsqldb:hsql://localhost:1701</property>
    <property name="connection.username">sa</property>
    <property name="connection.password"></property>

    <mapping resource="de/msg/dukesbank/integration/hibernate/Customer.hbm.xml"/>
    <mapping resource="de/msg/dukesbank/integration/hibernate/Account.hbm.xml"/>
    <mapping resource="de/msg/dukesbank/integration/hibernate/Tx.hbm.xml"/>
   ...
  </session-factory>
</hibernate-configuration>





The session Factory is obtained in this way:
Code:
    protected SessionFactory getSessionFactory() {
        try {
            return (SessionFactory) new InitialContext().lookup("java:hibernate/DukesBankSessionFactory");
        } catch (Exception e) {
            Log.error(this, "Could not locate SessionFactory in JNDI", e);
            throw new IllegalStateException("Could not locate SessionFactory in JNDI");
        }
    }



I persist entities like
Code:
sessionFactory.getCurrentSession().persist(someBO);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 7:49 am 
Newbie

Joined: Tue Nov 30, 2004 10:39 am
Posts: 10
the soultion is satted here:
http://forum.hibernate.org/viewtopic.php?t=949327

Alex.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.