-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate, Middlegen generated code, and DAO pattern
PostPosted: Mon Jul 24, 2006 3:33 pm 
Newbie

Joined: Mon Jul 24, 2006 3:21 pm
Posts: 14
My question is about best practices for using Hibernate in Java applications and the DAO pattern.

I jumped into a project that had some classes that another developer generated using Middlegen (MG). So, we have a DB and a mapping between DB tables and Java classes using Hibernate. What I want to know is: What else do I need to write in order to implement the DAO pattern? With just the MG generated classes, I find myself scattering Session related stuff all over my app in order to make sure collections are loaded (since we want lazy-loading) before I reference them.

Also, anytime I need to find a database object, I have to create Hibernate Criteria or Query objects. Should I instead write find() methods for each of the MG generated classes?

In order to properly implement the DAO pattern, should I have the MG classes implement DAO interfaces. In other words, if I have a 'book' table in my DB, should I write a Book interface and have MG generate a HibernateBookImpl class?

Any design help would be greatly appreciated. My main goal is to allow for lazy-loading of collections references without having any business layer code know anything about Hibernate or lazy-loading.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.