-->
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.  [ 4 posts ] 
Author Message
 Post subject: Custom JGeometryType and C3P0: java.lang.ClassCastException
PostPosted: Tue May 15, 2007 10:46 pm 
Newbie

Joined: Tue May 15, 2007 10:33 pm
Posts: 1
I have attached the full stack trace below. When C3P0 is enabled in the hibernate configuration file, the exception is thrown. When C3P0 is not used, everything works fine. It seems as though the nullSafeSet method of the JGeometryType custom user type (thanks for posting that by the way, works great!) creates its own connection and C3P0 gets angry and starts blurting out protocol corrections : )

If anyone has encountered this, any info would be most appreciated. I am not versed in the finer points of C3P0, so if this is ignorant I apologize in advance.

Hibernate version: Hibernate 3.2.3

Full stack trace of any exception that occurs:

java.lang.ClassCastException: com.mchange.v2.c3p0.impl.NewProxyConnection cannot be cast to oracle.jdbc.driver.OracleConnection
at ...persistence.JGeometryType.nullSafeSet(Unknown Source)
at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:156)
at org.hibernate.loader.Loader.bindNamedParameters(Loader.java:1753)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1679)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1563)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at ....hibernate.**HibernateDAO.findByGeography(Unknown Source)
at ....command.LookupCommand.execute(Unknown Source)
at ....CommandHandlerBean.executeCommand(Unknown Source)
at ....test.ILSTester.geoLookup(Unknown Source)
at ....test.ILSTester.main(Unknown Source)

Name and version of the database you are using:Oracle 10g R2


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 2:07 am 
Newbie

Joined: Fri May 25, 2007 1:34 am
Posts: 2
I am experiencing the exact same problem, getting the connection in the method nullSafeSet method throws the ClassCastException, at line:

OracleConnection connection = (OracleConnection) preparedStatement.getConnection();

Apparently some kind of conflict with the connection pool? So far unable to find a woraround/solution. Any information on this item yet, suggestions?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 3:21 am 
Newbie

Joined: Tue Mar 20, 2007 7:57 am
Posts: 2
you can check out the springs C3P0NativeJdbcExtractor for extracting the underlying Oracle connection.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 25, 2007 4:22 am 
Newbie

Joined: Fri May 25, 2007 1:34 am
Posts: 2
Thanks for your response, so did the following:

- added spring-1.2-rc1.jar

- added
import org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor;

- replaced the following code in nullSafeSet method from JGeometryType:

OracleConnection connection = (OracleConnection) preparedStatement.getConnection();

with:

C3P0NativeJdbcExtractor cp30NativeJdbcExtractor = new C3P0NativeJdbcExtractor();
OracleConnection connection = (OracleConnection) cp30NativeJdbcExtractor.getNativeConnection(preparedStatement.getConnection());


Works fine. Thanks for your help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.