-->
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: Good links for architecture
PostPosted: Sat Jun 03, 2006 10:30 pm 
Newbie

Joined: Fri Jun 03, 2005 11:36 am
Posts: 8
Hello friends -

I think I've got the basic O/R mapping deal down. What I seem to be lacking is the vision to put together an architecture to integrate Hibernate in and do things that way (I think) they should be done.

For example, I've got a parent child relationship I'd like to populate every time I grab the parent; and have those children be available to push into the session. I'd like to have Hibernate populate my set of children objects automatically. Finally, I'd like to have a simple DAO that allows calls from other layers that don't require other layers to understand Hibernate sessions, or anything else about persistence. These other layers could expect to get a series of fully populated objects back.

I feel like I must be missing something by coming to the consusion that this is impossible to handle in Hibernate; unless I were to develop a solution so unweidly, it would be easier to manage by just going ahead and writing the necessary getChildrenByParentId() methods everywhere and being done with it.

I feel like I'm at the point where I can brute force something together but get the feeling if I could see the big picture I would wind up with something much better.

Any advice is greatly appreciated.

- pD

_________________
I've got that sunny bunny feeling.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 04, 2006 4:07 am 
Newbie

Joined: Wed Oct 06, 2004 2:49 am
Posts: 12
Christian has written an excellent blog regarding this topic:

http://blog.hibernate.org/cgi-bin/blosx ... 2005/09/08


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 04, 2006 5:16 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
You need eager fetching.

You can try something like these in mapping files:
Code:
<set name="permissions"
            fetch="join">
    <key column="userId"/>
    <one-to-many class="Permission"/>
</set>

or
Code:
<many-to-one name="mother" class="Cat" fetch="join"/>



Or you can try something like this in HQL queries:
Code:
select
   p
from
   Person p
   left join fetch p.events
where
   p.id = :pid




read 19.1. Fetching strategies chapter in Hibernate reference


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 04, 2006 10:40 am 
Newbie

Joined: Fri Jun 03, 2005 11:36 am
Posts: 8
These are great examples, very helpful.

Thank you all.

- pD

_________________
I've got that sunny bunny feeling.


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.