-->
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: DAO pattern and granularity
PostPosted: Wed Jun 16, 2004 11:25 am 
Newbie

Joined: Wed Jun 16, 2004 9:54 am
Posts: 7
Hello!

I would like to abstract from the hibernate dependent code by using the DAO pattern. As I understand the pattern, there should be one DAO for each business object. This DAO implements CRUD operations which give access to the data of the business object.

By using this approach, however, a scalar query that returns properties from several classes cannot (efficiently) be implemented anymore. I would have to call one DAO method after another to gather the needed information. (Example: I would like to generate a summary table, that lists some properties of different classes).

If I were to implement a DAO which does not pertain to a particular business object and which implements special queries like these efficiently (using HQL) and gives me the result in a transfer object, would that be bad design?

Thanks a lot!
Jonas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 5:53 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
There's two options I've seen used. The one you mention, and another where the DAO for the main entity involved in the report/summary contains a method to gather all the required data.

I think either is a valid approach.

And, I don't think its a bad design. There is always going to be one-off use-cases which to not fit nicely into the arch. of the rest of the system. Things like on-the-fly reports within a OLTP system (basically what you are trying) are a good example.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 17, 2004 2:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
we are working with a "fine grained" DAO layer, it works fine, in your particular case... you'll have to write some "generic" or "exclusive" DAO.

What you can think about is "cutting" your domain model in 10 business zones (10 is an example ;) ), and have one DAO per zone.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: Thanks!
PostPosted: Thu Jun 17, 2004 3:34 am 
Newbie

Joined: Wed Jun 16, 2004 9:54 am
Posts: 7
Thank you very much for your input! Good to know I'm not off track.

Jonas


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.