-->
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: DataSource without JNDI
PostPosted: Sat Mar 11, 2006 10:40 am 
Newbie

Joined: Wed Sep 03, 2003 10:40 am
Posts: 6
Is there a way to configure Hibernate to use an existing DataSource instance without first putting the dataSource in JNDI?

I am already using a dataSource in the app and I don't like to duplicate information.

For example, it would be convenient if there was something like this:

hibConfig.setDataSource(myDataSource)

_________________
Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 11, 2006 12:19 pm 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
Hey,

do you use a kind of a "HibernateSessionFactory" where you get your Sessions from a SessionFactory? So you could use the following Code...

Code:
DataSourc dataSource = new DataSource(); // get it from somewhere
Session retVal = sessionFactory.openSession(dataSource.getConnection());


simon


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 12, 2006 3:27 pm 
Beginner
Beginner

Joined: Tue Jun 29, 2004 12:35 pm
Posts: 21
simonwillnauer wrote:

Code:
DataSourc dataSource = new DataSource(); // get it from somewhere
Session retVal = sessionFactory.openSession(dataSource.getConnection());



From Javadoc sessionFactory.openSession(dataSource.getConnection()):


Note that the second-level cache will be disabled if you supply a JDBC connection. Hibernate will not be able to track any statements you might have executed in the same transaction. Consider implementing your own ConnectionProvider.


But if you don't need second-level caching...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 4:51 am 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
In you app server you have a jndi datasource but for local testing or something similar you don't need to supply jndi datasource.....

that won't be a problem without the 2nd level cache...

simon


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.