-->
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.  [ 4 posts ] 
Author Message
 Post subject: Any sense in making 2 sets of DAOs - Hibernate & normal
PostPosted: Thu Jan 27, 2005 4:22 pm 
Newbie

Joined: Thu Jan 27, 2005 4:10 pm
Posts: 6
Hi there

I am wondering - have you ever encountered situation, when you want to do something more than simple CRUD ? For example joining some tables, counting sth and then put that in the databean ?

Cause as far as I know you cannot do that in simply and elegand manner in Hibernate. So will finish with two sets of DAOs- one wich is using hibernate and is used for simply gimmie all Apples, create Apple, etc, and one for more complicated queries like gimmie Apples that were in top 10 number of sells, with count of how many were sold and who was the most frequent buyer (yea, I know stupid, but whatever, it's simply and example if you don't like it think about some twisted finance/shipment report).

As far as I was told, I can do that in hibernate, but I will finish with executing plain SQL and then iterating over arrays of objects as a result.

So how are you handling those issues in your real-life apps ?

thank you in advance for any hints / help

regards
Leszek


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 27, 2005 4:42 pm 
Senior
Senior

Joined: Sun Oct 26, 2003 5:05 am
Posts: 139
I never really separate my manipulation statements from my query statements. They can all easily go in the same DAO. I just place the query with the DAO of the object that it returns. The queries can get as complicated as you want them to be.

However, I've seen some people name two DAOS something like ApplePersister and AppleRepository.

However, since store/delete/update is typically just 2 or maybe a few more methods in the DAO, it's usually not worth the separation since most of the DAO will be queries anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 29, 2005 3:30 am 
Newbie

Joined: Thu Jan 27, 2005 4:10 pm
Posts: 6
And you are passing to 'normal' DAO methods Hibernate objects as a parameters (for connection, etc), or plan Connection ?

thanks,
Leszek


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 11:16 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
xnts wrote:
And you are passing to 'normal' DAO methods Hibernate objects as a parameters (for connection, etc), or plan Connection ?

thanks,
Leszek


One of the main functions of the DAO pattern is to encapsulate the data store access, so you probably wouldn't want to require callers to supply things like JDBC connections or Hibernate Sessions. These data store resources should be supplied by a dependency injection framework like Picocontainer, Spring, or a home grown dependency injector of some sort.


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