Register / Login
this forum made possible by our volunteer staff, including ...
Stephan van Hulst
Object Relational Mapping
Hibernate: XML-Mapping to list without index column, or some other workaraound ...
posted 4 years ago
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
posted 4 years ago
Can I use a <composite-element>, and if yes, how?
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
Boost this thread!
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