-->
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: static vs. JNDI
PostPosted: Fri Feb 06, 2004 10:05 am 
Newbie

Joined: Tue Nov 11, 2003 6:24 pm
Posts: 17
Could someone explain the pros and cons of placing a Hibernate SessionFactory into a static variable in the VM vs. inside JNDI for a web application?

Our application places SessionFactory into JNDI and we've found this to be problematic for testing our business logic with JUnit. We're consider just storing SessionFactory as a static in a singleton helper class. Is there a downside to this that I am unaware of?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 10:18 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
Why not simply a singleton that can use JNDI in a web-app and a static variable in a JUnit test ?
Ciao.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 10:25 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
There is no difference, both implement the Registry pattern. Depends on what your other frameworks or your application uses.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 06, 2004 10:25 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh, and JNDI is a standardized Registry API :)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Re: static vs. JNDI
PostPosted: Fri Feb 06, 2004 12:18 pm 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
aharvey wrote:
Our application places SessionFactory into JNDI and we've found this to be problematic for testing our business logic with JUnit. We're consider just storing SessionFactory as a static in a singleton helper class. Is there a downside to this that I am unaware of?


It's still possible to use in unit tests. Just populate context yourself.


Placing session factory in JNDI gives you advantages if you like to
be able to exchange / reconfigure session factory without restarting
web app, or share it between 2 webapps / ejb tiers / whatever

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject: Re: static vs. JNDI
PostPosted: Mon Feb 09, 2004 5:57 am 
Newbie

Joined: Tue Jan 27, 2004 3:26 pm
Posts: 18
aharvey wrote:
Our application places SessionFactory into JNDI and we've found this to be problematic for testing our business logic with JUnit.



Try 'JUnit JNDI DataSource helper package' (http://www.javaranch.com/codebarn.jsp).

regards,
Artur


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.