-->
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: JBoss-Hibernate error : Cannot set autocommit to true
PostPosted: Sat Mar 26, 2005 8:11 am 
Newbie

Joined: Sat Mar 26, 2005 7:55 am
Posts: 5
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.7
Mapping documents:

Code between sessionFactory.openSession() and session.close():
session.save(<dataModel>)
Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

hello all,

i am using hibernate 2.1.7 with jboss 4.0.1 , the hibernate is NOT deployed as a service in jboss.
I have configured a dataSource with MySQL db to use with hibernate.

My problem is whenever i use the data source with hibernate within a UserTransaction i get the error "cannot set autocommit to true in a managed transaction" .

If i use the c3p0 connection pool , then i dont get the error , the operation succeeds , however , the record doesnt appear in the database table !!

please help , this is the code in my unit test :

UserTransaction transaction = (UserTransaction)
ServiceLocator.getInstance()
.lookup(ServiceLocator.USER_TRANSACTION);

transaction.begin();
Company company = new Company();
company.setName("manu1");
company.setOwnership(false);
dao.create(company);
transaction.commit();
assertNotNull("company id should not be null" , company.getId());

the code inside the dao looks like this :

Session session = config.openSession();
try{
object.setCreationDate(new Timestamp(System.currentTimeMillis()));
session.save(object);
}catch(Exception e){
logger.error("error in save() , ", e);
throw new ApplicationException(e);
}
session.close();


my hibernate properties are :

#hibernate.connection.datasource=java:/MySqlDS
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost/dtlp
hibernate.connection.username=test
hibernate.connection.password=test
hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=1800
hibernate.c3p0.max_statements=50
hibernate.dialect = net.sf.hibernate.dialect.MySQLDialect

hibernate.show_sql=true
hibernate.generate_statistics=true

hibernate.transaction.factory_class=net.sf.hibernate.transaction.JTATransactionFactory
hibernate.transaction.manager_lookup_class=net.sf.hibernate.transaction.JBossTransactionManagerLookup
hibernate.jta.UserTransaction=UserTransaction


any help would be greatly appreciated , i am on a tight deadline :-)

regards,
manu


Top
 Profile  
 
 Post subject: got it !
PostPosted: Sat Mar 26, 2005 8:51 am 
Newbie

Joined: Sat Mar 26, 2005 7:55 am
Posts: 5
mea culpa ,

i found the solution http://forum.hibernate.org/viewtopic.php?t=935847

i was using hi/lo algorithm for generating primary keys which require a autocommit so cannot be used with JTA.

i need to change my primary key strategy.

anyways , thanks for anyone who viewed this topic

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.