-->
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: Do we really need a set of DAO classes?
PostPosted: Fri Jan 23, 2009 2:24 am 
Newbie

Joined: Fri Jan 23, 2009 2:13 am
Posts: 1
All of the Hibernate and J2EE books that I've seen seem to recommend a layer of DAOs where each DAO has an add, update, delete and one or more query methods for a certain object type (i.e. business object) for a J2EE web application. Any reason not to make one set of add(), update() and delete() methods on a class named something like PersistenceManager that uses reflection to determine the business object type and perform the requested persistence operation rather than making a bunch of DAOs that just delegate to Hibernate for a specific object type?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 23, 2009 4:18 am 
Newbie

Joined: Tue Jan 13, 2009 11:49 am
Posts: 11
granted, lots of methods in DAOs are cookie-cutter style. But there are lots of situations where you want to add functionality or hide implementation. Just like using setter / getter methods in your pojos and not accessing the attributes directly.

Example 1: You may want to fire an event every time you update an item that fullfills certain filter criteria.

Example 2: You want queries that hide implementation. you might want to make a query method like findPeopleIneedToFireToday(). The construction of the query would be well hidden from the developer using the DAO.

dirk


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.