-->
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: Mapping a Bill of Material With Associated Tables
PostPosted: Tue Aug 02, 2011 2:27 pm 
Newbie

Joined: Sun Jul 12, 2009 9:38 pm
Posts: 3
I'm planning to map a bill of material structure, where each node needs to be joined to another table based on a column value determined at run time. Rows from this second table appear as a Set in the node POJO. There are many rows in the joined table that belong to each node, but I don't want any that don't satisfy the criterion.

Since it's a bill of material, the top nodes have child nodes (also a Set) which are of the same class the top nodes are, and so on.

Ideally I'd write something like this to get the top-level nodes and get to the associated row via the Set in the node's instance:

Code:
select from Node n  outer join fetch Associate a
where a.field = "x"


Unfortunately, as I understand it, I can't have a WHERE clause on the associated table when using "fetch;" but NOT using "fetch" doesn't yield the associated row embedded in the node's POJO.

But I want even more than that! I'd like to iterate over the child Nodes (the second Set mentioned above) Hibernate-style and automatically pull in their associated rows too--using the same criterion with which I chose associated rows at the top of the structure.

Can this be done via a Hibernate mapping? Can it be done the basic POJOs that define the two classes involved? Will I have to define a view in my database (one that joins the tables involved) to pull this off--and if so, how can I map both the view and the original tables to the POJOs?

Thanks for your help.


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.