-->
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.  [ 5 posts ] 
Author Message
 Post subject: Passing DataSource to Configuration directly?
PostPosted: Thu Apr 26, 2007 7:19 pm 
Newbie

Joined: Thu Feb 03, 2005 9:19 pm
Posts: 11
Location: Bedford, TX
Is there a way to pass a DataSource object directly to a Configuration or AnnotationConfiguration object rather than via a JNDI context? If not, how should this be approached when writing a stand-alone application where you want to use Hibernate Annotations? Please do help.

Hibernate version: 3.2.3
Hibernate Annotations version: 3.3.0

Thanks,
Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 7:32 pm 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
For stand alone operation Hibernate can connect to the database directly rather than using a data source. You can still use a connection pool to get decent performance.

Check out the [JDBC Connections|http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html#configuration-hibernatejdbc] section of the documentation.


Top
 Profile  
 
 Post subject: Unfortunate
PostPosted: Thu Apr 26, 2007 11:37 pm 
Newbie

Joined: Thu Feb 03, 2005 9:19 pm
Posts: 11
Location: Bedford, TX
This is unfortunate, and quite a limitation as I see it. I'm familiar with the linked docs. Note this quote from that section:

Quote:
It is intended to help you get started and is not intended for use in a production system or even for performance testing.


So it looks like I'm going to slap together a really cheap and hacky java.naming.Context just for passing this object. Very sad.

Thanks for the answer none the less.

Daniel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 12:47 am 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
Read a little further. The built in connection pool is not intended for production use, but hibernate integrates with several connection pools that are. The usage of C3PO is documented right below the stuff on the hibernate connection pool

If you use one of these pools rather than hibernate's built in one then hibernate can be used stand alone without having to hack up a naming context.

Of course if you really want a stand alone naming context, the Tomcat one is easy to deploy stand alone.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 27, 2007 6:17 pm 
Newbie

Joined: Thu Feb 03, 2005 9:19 pm
Posts: 11
Location: Bedford, TX
Ahh, cool, thanks! :) Then again, I've been using the oracle.jdbc.pool.OracleDataSource. I presume it's of high quality, although I don't know it very well and have had problems with connection leaks (could be my fault though). Either way, my application is internal anyway and only takes a few hits per minute.

Too bad we can't use a BeanFactory like you can do in Tomcat's config files, where you can instantiated and initialize arbitrary bean objects.

Thanks again for your help

Daniel


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