-->
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: accessing c3p0 physical connection
PostPosted: Fri Sep 23, 2005 5:53 pm 
Newbie

Joined: Fri Sep 23, 2005 5:34 pm
Posts: 3
Hibernate version:
2.1.8

Mapping documents:
N.A.

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

Full stack trace of any exception that occurs:
N.A.

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

The generated SQL (show_sql=true):
N.A.

Debug level Hibernate log excerpt:
N.A.

We are working with Hiberate and using the default c3p0 as the connection pool provider.
The problem is that we need to perform several SQL statements (alter session...) on a physical connection once it's been created (and to perform them only once).

I thought of two solutions to our problem, and can't find a way of implementing either one of them:
1. registering at c3p0 to get notified about physical connection creation, where I can perform the statements I need on the created connection.
2. whenever opening a new Hibernate Session, check if its physical connection was handled by me. If it wasn't, handle it and keep it in some static Set for next time.

I couldn't find a way of registering for events at c3p0, or to access the physical connection of a Session (using Session.connection() retrieves a connection proxy, which is new every time a new Session is opened).

Assistance on implementing any of the mentioned solutions or an alternative solution is welcomed.

Thanks,
Yoram


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 25, 2005 4:31 am 
Newbie

Joined: Fri Sep 23, 2005 5:34 pm
Posts: 3
I found the answer on another thread :-)
you can get the physical (native) connection by calling:

session.connection().getMetaData().getConnection()


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.