-->
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.  [ 3 posts ] 
Author Message
 Post subject: DAO design with Hibernate
PostPosted: Tue Oct 05, 2004 5:30 am 
Beginner
Beginner

Joined: Tue Oct 05, 2004 5:15 am
Posts: 23
Hi,

Im new to Hibernate - and to ORM. In the past I've used the DAO pattern in combination with DTOs to abstract data access. It worked nicely for me, but I hated the feeling that I was loosing an object oriented domain model.
So, on my new project, even though my domain model is relatively simple, I've decided to go with Hibernate. However, I've run in to a brick wall when trying to design a DAO. I've done a "DAO" search on this forum and have found useful information, but Im still confused on a couple of points.
Suppose I have an Order and and OrderItem. One business process might be to add an OrderItem to an existing Order.
So, I can use my DAO to locate the Order, create a (POJO) OrderItem, and add it to the Order.
Thanks to the power of Hibernate, thats it.... At the transaction demarcation point, the session will be flushed, and everything will be updated correctly (due to the options I've used in my mapping).

What Im finding is that although my DAO hides Hibernate access (which is great, as all my finders etc are in one place), I still get a sinking feeling that Im doing something "the wrong way". As my DAO stands, there is just no way I could swap in another implementation. The thing that niggles me about my DAO implementation is that some of the operations are channeled through the DAO "createOrder(Order o)", and others rely on "the magic of Hibernate" (adding an OrderItem to an existing Order "just works"). Has anyone else come across this "problem" or have any suggestions?
Id just like to have that "Im on the right track" feeling :o)

Thanks,

Dave


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 06, 2004 7:14 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
What you feel is that you've not abstracted he ORM notion of session / unit-of-work.
Have a look at whet SpringFramework have done.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 08, 2004 3:42 am 
Beginner
Beginner

Joined: Tue Oct 05, 2004 5:15 am
Posts: 23
emmanuel wrote:
What you feel is that you've not abstracted he ORM notion of session / unit-of-work


That was was exacactly what I needed!
I'd never heard of Unit-Of-Work before (I really should read Patterns of Enterprise Application Architecture). Looking at it that way, it all makes much more sense!

Thanks!

Dave


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