-->
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: Transaction not commited to db
PostPosted: Tue May 24, 2005 3:07 am 
Newbie

Joined: Tue May 24, 2005 2:08 am
Posts: 1
Simple query executed in stateless session bean does not commit to database. Hibernate seems to execute commit correctly but data doesn't come visible to other database users.

Works correctly if I remove c3p0.* & connection.url from hibernate.properties and add line:
Code:
connection.datasource=java:jdbc/MyDB

and define jdbc/MyDB as:
Code:
<datasources>
<local-tx-datasource>
  <jndi-name>jdbc/MyDB</jndi-name>
    <connection-url>jdbc:mysql://localhost/test</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>xxx</user-name>
    <password>xxx</password>
  </local-tx-datasource>
</datasources>


Is there something wrong in my configuration or does there exist an bug? I tried to debug this for a quite a while but found no appropriate solution.

Application server: JBoss AS 4.0.2

Hibernate version: 3.0.3

Mapping documents:
hibernate.properties:
Code:
connection.driver_class=com.mysql.jdbc.Driver
connection.url=jdbc:mysql://127.0.0.1:3306/test
connection.username=xxx
connection.password=xxx
transaction.factory_class=org.hibernate.transaction.JTATransactionFactory
transaction.manager_lookup_class=org.hibernate.transaction.JBossTransactionManagerLookup
transaction.flush_before_completion=true
transaction.auto_close_session=true
dialect=org.hibernate.dialect.MySQLInnoDBDialect
show_sql=true
c3p0.min_size=1
c3p0.max_size=10
c3p0.timeout=1800
c3p0.max_statements=50
cache.use_second_level_cache=false


ExampleUser mapping:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="ExampleUser" table="user" proxy="ExampleUser">
  <id name="id" column="US_PK_OID">
   <generator class="native"/>
  </id>
  <version name="version" column="US_VERSION"/>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Code:
tx = session.beginTransaction();

// Create one user
ExampleUser user = new ExampleUser();
session.save( user );

// Everyting went ok, commit transaction
tx.commit();



Name and version of the database you are using:MySQL, version: 4.1.12-nt

JDBC driver:MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.8

Debug level Hibernate log excerpt:
Code:
DEBUG [JDBCContext] no active transaction, could not register Synchronization
DEBUG [SessionImpl] opened session at timestamp: 11169174152
DEBUG [JTATransaction] begin
DEBUG [JTATransaction] Looking for UserTransaction under: UserTransaction
DEBUG [JTATransaction] Obtained UserTransaction
DEBUG [JTATransaction] Began a new JTA transaction
DEBUG [JDBCContext] successfully registered Synchronization
DEBUG [DefaultSaveOrUpdateEventListener] saving transient instance
DEBUG [AbstractSaveEventListener] generated identifier: , using strategy: org.hibernate.id.IdentityGenerator
DEBUG [AbstractSaveEventListener] saving [ExampleUser#<null>]
DEBUG [AbstractSaveEventListener] executing insertions
DEBUG [Versioning] using initial version: 0
DEBUG [BasicEntityPersister] Inserting entity: ExampleUser (native id)
DEBUG [BasicEntityPersister] Version: 0
DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG [AbstractBatcher] opening JDBC connection
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool] resource age is okay: com.mchange.v2.c3p0.impl.NewPooledConnection@6a9e79 ---> age: 408254   max: 1800000 [com.mchange.v2.resourcepool.BasicResourcePool@1546c85]
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool] trace com.mchange.v2.resourcepool.BasicResourcePool@1546c85 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@6a9e79)
DEBUG [org.hibernate.SQL] insert into user (US_VERSION) values (?)
INFO  [STDOUT] Hibernate: insert into user (US_VERSION) values (?)
DEBUG [AbstractBatcher] preparing statement
DEBUG [GooGooStatementCache] GlobalMaxOnlyStatementCache ----> CACHE HIT
DEBUG [GooGooStatementCache] checkoutStatement: GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 1; num connections: 1; num keys: 2
DEBUG [BasicEntityPersister] Dehydrating entity: [ExampleUser#<null>]
DEBUG [org.hibernate.type.IntegerType] binding '0' to parameter: 1
DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 2
DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG [AbstractBatcher] closing statement
DEBUG [GooGooStatementCache] checkinStatement(): GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
DEBUG [JTATransaction] commit
DEBUG [CacheSynchronization] transaction before completion callback
DEBUG [CacheSynchronization] automatically flushing session
DEBUG [SessionImpl] automatically flushing session
DEBUG [AbstractFlushingEventListener] flushing session
DEBUG [AbstractFlushingEventListener] processing flush-time cascades
DEBUG [AbstractFlushingEventListener] dirty checking collections
DEBUG [AbstractFlushingEventListener] Flushing entities and processing referenced collections
DEBUG [AbstractFlushingEventListener] Processing unreferenced collections
DEBUG [AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
DEBUG [AbstractFlushingEventListener] Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
DEBUG [AbstractFlushingEventListener] Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG [Printer] listing entities:
DEBUG [Printer] ExampleUser{id=2, version=0}
DEBUG [AbstractFlushingEventListener] executing flush
DEBUG [AbstractFlushingEventListener] post flush
DEBUG [JDBCContext] before transaction completion
DEBUG [SessionImpl] before transaction completion
DEBUG [CacheSynchronization] transaction after completion callback, status: 3
DEBUG [JDBCContext] after transaction completion
DEBUG [SessionImpl] after transaction completion
DEBUG [CacheSynchronization] automatically closing session
DEBUG [SessionImpl] automatically closing session
DEBUG [SessionImpl] closing session
DEBUG [AbstractBatcher] closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
DEBUG [GooGooStatementCache] checkinAll(): GlobalMaxOnlyStatementCache stats -- total size: 2; checked out: 0; num connections: 1; num keys: 2
DEBUG [com.mchange.v2.resourcepool.BasicResourcePool] trace com.mchange.v2.resourcepool.BasicResourcePool@1546c85 [managed: 1, unused: 0, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@6a9e79)
DEBUG [JDBCContext] after transaction completion
DEBUG [SessionImpl] after transaction completion
DEBUG [JTATransaction] Committed JTA UserTransaction
DEBUG [SessionImpl] closing session


My EJB bean (Stateless session bean) configuration:
Code:
<enterprise-beans>
<session>
  <ejb-name>MyEJB</ejb-name>
  <home>MyEJBHome</home>
  <remote>MyEJB</remote>
  <ejb-class>MyEJBClass</ejb-class>
  <session-type>Stateless</session-type>
  <transaction-type>Container</transaction-type>
</session>
</enterprise-beans>

<assembly-descriptor>
<container-transaction>
  <method>
   <ejb-name>MyEJB</ejb-name>
   <method-name>*</method-name>
  </method>
  <trans-attribute>NotSupported</trans-attribute>
</container-transaction>
</assembly-descriptor>


Table User created as:
Code:
CREATE TABLE user
  (US_PK_OID int primary key auto_increment,
   US_VERSION INT)
type=InnoDB;


Top
 Profile  
 
 Post subject: you need to use a datasource
PostPosted: Mon May 30, 2005 6:53 am 
Newbie

Joined: Tue Dec 09, 2003 8:04 am
Posts: 5
hi,

i ran into the same problem and had to work with the datasource.
the connections obtained from c3p0 maybe dont participate in j2ee transactions !

manu


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.