The moose likes Object Relational Mapping and the fly likes Cannot get Hibernate 3.1 to work with c3p0 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Cannot get Hibernate 3.1 to work with c3p0" Watch "Cannot get Hibernate 3.1 to work with c3p0" New topic
Author

Cannot get Hibernate 3.1 to work with c3p0

Chris Johnston
Ranch Hand

Joined: Dec 13, 2004
Posts: 85
This is driving me crazy. Especially since I cannot seem to find any info
about the problem on Google.

Here is the deal, I have set up Hibernate and as long as I use its built in
JDBC connection pooling, everything works fine. However, as soon as I try
and use c3p0, nothing works. I have a JUnit test class that tests my
PersistenceDAO against a live MySQL 4.x database. Basically, it tries to
insert, update, delete a bunch of objects to make sure that Hibernate is
working correctly. This works fine, all tests pass, if I don't use c3p0. As
soon as I turn it on, not a single test passes. I have no idea what is going
on here. In an attempt to answer as many questions as possible, please see
below:

IDE: NetBeans 5.0

Hibernate: version 3.1 using the library version that come bundled with it.
c3p0: version c3p0-0.9.0.jar (I have tried the latest version as well,didn't work)
MySQL: version 4.1.20 running on CentOS 4.3
JDBC: mysql-connector-java-3.1.12-bin.jar

Below are my hibernate config file and, as far as I can tell, the important
parts from the stack trace. As you can see from the config file, I am using
what is more or less a default use of c3p0, but nothing is working. Below
everything, I have also included the source code from one of the methods
from my PersistenceDao class in case the problem is in the code.

Thanks for the help with this,
Chris


hibernate.cfg.xml


The stacktrace



PersistenceDao method


[ July 03, 2006: Message edited by: Chris Johnston ]
[ July 03, 2006: Message edited by: Chris Johnston ]

www.fuzzylizard.com
Chris Johnston
Ranch Hand

Joined: Dec 13, 2004
Posts: 85
I seemed to have fixed the problem, but I don't really understand how. I commented out the following statement in my hibernate.cfg file and the tests passed



I don't understand why that would make such a big difference. Can someone explain this please?
ravi bhosale
Greenhorn

Joined: Jun 17, 2006
Posts: 5
Hi,

Me to also faced problem with Hibernate 3.1.2 and c3po. Finally its solved by building source of c3p0-0.9.0.2.

For me problem is because of different log4j version used by Hibernate and C3po. But now its working.
Nobody Cares
Greenhorn

Joined: Aug 16, 2006
Posts: 1
I am experiencing exactly the same issue...has anyone resolved this issue since the initial post?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

"Nobody Cares",

You are quite inccorect. We do care! Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
nirumagic tniranjan
Greenhorn

Joined: Aug 17, 2006
Posts: 4
hi, try as in below.

session.saveOrUpdate(object);
session.commit();


If you want use connection pooling better use jndi lookup. It is the best practise and nice performence.
 
 
subject: Cannot get Hibernate 3.1 to work with c3p0
 
Threads others viewed
retrieving object hierarchy - many-to-one?
Null PointerException at Configuration.buildSessionFactory
Trouble in setting up JFORUM with Eclipse as a Tomcat Project
Exception on SessionFactory.close()
Exception in example Using Hibernate Entity Manager in 2nd chapter of Java Persistence WithHibernate
developer file tools