-->
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: DAO Design Pattern
PostPosted: Wed May 24, 2006 8:21 am 
Newbie

Joined: Fri Aug 05, 2005 10:38 am
Posts: 11
Hi,

i am currently writing a portal where portlets(modules) need access to the persistence layer, but the use cases of a portlet can not be foreknown.
Because of this i can not use Seam, because Seam uses a (Stateful)Bean per Use Case which i can not foreknown. So i need somethink like a facade where i can give over persistent (not detached) entity beans to the portlets.

In caveatemptor i found the DAO-Pattern which is really nice. I implement the DAOs (like UserDAO, GroupDAO) as Statefull SessionBeans (SFSB) and the DAOFactory looks the up via JNDI.

This works nice but my unit of work is not atomic anymore, because each DAO SFSB has it's own ExentedEntityManager. The conclusion is that i need
something like a Context (Application, Session, Request, Event, ...) in Seam.

Unfortunatelly it is not possible (ends up in "horrible exception or undefiend behavior" in JBoss EJB3.0 Forum) to give out the EntityManager of a SFSB which includes share the EntityManager between SFSBs. The possibility to inject every DAO SFSB in something like a Context SFSB to share the lifetime and the entityManager is an antipattern, because for each new Context ALL DAOs have to be created which is really inefficient.
I also read "Chapter 1.2.4. Persistence context propagation" of Hibernate EntityManager documentation, but i didn't get any additional ideas about the problematic.

An other alternative would be something like a command pattern. I would have a Context SFSB which is the command executor and the DAO SFSB only creates Command Implementations and send it to the Executor.

So any idea how to solve my problem?

Regards

Peter


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 24, 2006 2:59 pm 
Regular
Regular

Joined: Thu Sep 22, 2005 1:53 pm
Posts: 88
Location: Rio de Janeiro
Hi,

This not so much an answer to your question as it is a hint to ...
Take a closer look at the DAO pattern if you want to use it:

[url=http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html]
DAO Pattern [/url]

It seems to me that it´s not such a good idea to implement your DAO´s
as Session Beans Statless or Statefull....

Greetings.....[/url]

_________________
Don´t forget to rate!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 2:06 pm 
Newbie

Joined: Fri Aug 05, 2005 10:38 am
Posts: 11
i use EJB 3. The DAO-Pattern is from caveatemptor. Perhaps you should look at it. It is really cool and also implements DAOs as Session Beans.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 26, 2006 3:28 pm 
Newbie

Joined: Fri Aug 05, 2005 10:38 am
Posts: 11
any other idea?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 29, 2006 2:24 am 
Newbie

Joined: Fri Aug 05, 2005 10:38 am
Posts: 11
i can't believe nobody had a similar problem.


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.