-->
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.  [ 6 posts ] 
Author Message
 Post subject: Retreiving JDBC connection from EntityManager
PostPosted: Mon Dec 19, 2005 9:10 am 
Newbie

Joined: Fri Nov 25, 2005 8:36 am
Posts: 7
Is there a way to get the JDBC connection used by an entity manager ?

On one hand, I have legacy code that uses plain old JDBC code that I wish to reuse, and on the other hand, I am in a J2SE application context, and I prefer to use one EntityManager/Connection for all the application life span. My database is HSqldb and it don't support multiple connections.

I have found another EJB3 implementation from Kodo by SolarMetric, where EntityManger provides a "getConnection()" method that seems to fit the bill ( http://www.solarmetric.com/Software/Documentation/4.0.0EA/docs/javadoc/kodo/persistence/KodoEntityManager.html), and I was wondering if Hibernate offers a way to do the same.

Thanks,
Robert


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 1:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
( (HibernateEntityManager) em).getSession().connection();

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 20, 2005 4:23 am 
Newbie

Joined: Fri Nov 25, 2005 8:36 am
Posts: 7
Couldn't be simpler, thanks.
Robert


Top
 Profile  
 
 Post subject: deprecated
PostPosted: Thu Mar 06, 2008 12:15 pm 
Newbie

Joined: Tue Sep 05, 2006 10:39 am
Posts: 13
In Hibernate 3.2.5ga, Session.connection() has been deprecated.

Is there a better way to obtain the connection now?

Thanks

_________________
Please rate my post, thanks.

Those are my principles. If you don't like them I have others. -- Groucho Marx


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 08, 2008 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
depends on the environment? In EE, just inject the Datasource

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 08, 2008 1:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
generally speaking this problem will be addressed in hibernate 3.3

_________________
Emmanuel


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