-->
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: To explicitly initialize, or not
PostPosted: Fri Nov 04, 2005 5:09 am 
Newbie

Joined: Fri Nov 04, 2005 4:47 am
Posts: 14
I'm currently taking Hibernate for a spin, and have a question about design. I'm working on a screen which displays a list of contracts. Each contract has three associations, "buyer", "seller" and "broker". These are all instances of Company. In addition, each Company instance has a Country instance, and in my list I need to display the name of the country.

I've also added:
.setFetchMode("buyer", FetchMode.JOIN)
.setFetchMode("seller", FetchMode.JOIN)
.setFetchMode("broker", FetchMode.JOIN)

To the criteria I'm using to fetch these, so that these associations are eagerly fetched. I've noticed however that the country table is being repeatedly queried to get the name of the country (which is the only Country property shown in the view I'm working on). So I added this:

criteria.createCriteria("seller").setFetchMode("country", FetchMode.JOIN);
criteria.createCriteria("buyer").setFetchMode("country", FetchMode.JOIN);
criteria.createCriteria("broker").setFetchMode("country", FetchMode.JOIN);

To eagerly fetch the countries as well.

But what I really want is to have the entire graph initialized because I'm going to display values from all the associations anyway.

I've also considered creating a simpler version of the Contract object, because I really just need the name, and country name from each involved company. Basically I'd "flatten" the object graph into a more table-like structure, where instead of an entire company object I just have the company name and country as Strings. But I'm not exactly sure how I can do this, because it basically involves mapping up a query rather than a single table.

But I guess what I'm after is opinions, ideas, links to tutorials etc. about what is the best (or at least a good) approach to this sort of thing. I'm thinking it's not too uncommon to have fairly large objects and situations where you need to just list a small selection of the object properties for a large number of objects.


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.