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.  [ 7 posts ] 
Author Message
 Post subject: Testing outside container with getCurrentSession
PostPosted: Fri Sep 09, 2005 11:07 am 
Newbie

Joined: Wed Feb 11, 2004 7:50 pm
Posts: 10
Hi,

I'm deploying my hibernate classes as an har archive on JBoss. To get a session I call the getCurrentSession method of the SessionFactory in my data access objects.

This won't work if I want to test my DAO's outside the container. Because the the DAO object doesn't not execute in the context of an JTA transaction.

Is there a method to test my dao's outside the container?

Thanks anyway,

Joris Wijlens


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 11:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why would you do this? A DAO should only be tested for correct integration. Integration testing requires the infrastructure that is tested.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 11:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh, and if you absolutely want to, you can use a trivial wrapper around the getCurrentSession() method that falls back to thread local handling of the Session: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 4:18 am 
Newbie

Joined: Wed Feb 11, 2004 7:50 pm
Posts: 10
christian wrote:
Why would you do this? A DAO should only be tested for correct integration. Integration testing requires the infrastructure that is tested.


Can you explain this to me? Why should a DAO only be tested for correct integration? A link should also be fine.

Joris


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 5:23 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
What _else_ would you test your DAO for? That you can correctly instantiate one? That the method you are calling exists?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 8:25 am 
Newbie

Joined: Wed Feb 11, 2004 7:50 pm
Posts: 10
christian wrote:
What _else_ would you test your DAO for? That you can correctly instantiate one? That the method you are calling exists?


I'd like to test if the DAO gives me the right results (correctness of my queries) , if my mapping is correct these kind of things. An integration test without the session beans being in scope.

Joris Wijlens


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 8:28 am 
Newbie

Joined: Wed Feb 11, 2004 7:50 pm
Posts: 10
christian wrote:
Oh, and if you absolutely want to, you can use a trivial wrapper around the getCurrentSession() method that falls back to thread local handling of the Session: http://hibernate.org/42.html


By the way thanks a lot. This link is usefull.

Joris


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