-->
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.  [ 2 posts ] 
Author Message
 Post subject: EntityManager within Business Object and Data Access Object
PostPosted: Tue Nov 21, 2006 7:54 am 
Regular
Regular

Joined: Sat May 20, 2006 3:49 am
Posts: 78
Hello,

I'm developing a 2-tier Rich-Client Application with Hibernate 3.2 and Eclipse 3.2.1 RCP Framework.

Today I have read a lot about the Thread-Local Session Patterns which is used under my RCP Java SE Environment. So my first design of Business Objects and Data Access Objects was the following:

1) I have a global EntityManagerFactory, where I get my EntityManagers from
2) My Business Objects request a EntityManager from my EntityManagerFactory
3) My Business Objects open and close the Transactions as they are needed with EntityManager.getTransaction.begin()
4) My Business Objects call my DAOs, which make the operations with the database, for example EntityManager.persists(record) or EntityManager.remove(record).

Now my question:
If one of my Business Objects get an EntityManager from the factory and open a transaction, I have an opened session in my current thread.

How is it possible for my DAOs to get this session to make any operations? Do I have to call Session.remove() or EntityManager.remove().

Regards

Christoph


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 23, 2006 1:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Check SF.getCurrentSession() in the documentation, you should be able to apply those patterns

_________________
Emmanuel


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