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