File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Object Relational Mapping
Hibernate: XML-Mapping to list without index column, or some other workaraound ...
Joined: May 27, 2012
Dec 19, 2012 05:18:25
Hello everyone. I'm quite new to Hibernate and need help in a hopefully simple task.
I do have: An XML mapping of table A to class A.java.
I do have: Another table B that has a common column with A (its value is key in A, but can occur more than once in B), and 2 other columns that I do need in the mapping to class A.
I can map a column region to a Set like this in the XML mapping of table A:
<set name="name of the Set" inverse="false" lazy="false" table="B" fetch="select"> <key> <column name="the common column" not-null="true" /> </key> <many-to-many entity-name="de.test.A"> <column name="one of the 2 other columns in B" not-null="true" /> </many-to-many> </set>
... and do the same for the other column.
But, this does not help me since the order of a Set can be random, and if I get 2 Sets I can't know which values read from B's 2 other columns were in the same row. I do however need this information.
I too can't use mappings to List since B has no index column. (Or is there some way to auto-simulate the existence of one?)
Does anyone know how I can work around my problem? What in need in my
is the result of
SELECT column_2, column_3 FROM B WHERE column_1 = :theIdOfA;
Thanks in advance and kind regards
Joined: May 27, 2012
Dec 19, 2012 08:51:00
Can I use a <composite-element>, and if yes, how?
It is sorta covered in the
JavaRanch Style Guide
subject: Hibernate: XML-Mapping to list without index column, or some other workaraound ...
Loading Into Random Table
validator exception in Struts 1
Table Viewer GUI from a Database
Fetch 10K rows from table
How to avoid empty tag when marshalling using Castor 1.2
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015