Hi
I have a mapping problem, that I need some help with.
Here is a very simple version of my problem.
My database looks like this:
Code:
-------------- ---------------
| foo | | bar |
-------------- ---------------
*| int P | *| int P |
*| int U | *| int S |
| int S | *| int L |
-------------- ---------------
*=primarykey
So from foo you will get a list of bar if you use P and S as the key.
My two classes foo and bar looks like this:
Code:
public class foo{
private Id id;
private Integer s;
private Collection barList;
public static class Id implements Serializable {
private Integer p;
private Integer u;
...........
}
.........
}
public class bar{
public static class Id implements Serializable {
private Integer p;
private Integer s;
private Integer l;
.........
}
.......
}
The mapping files look like this:
Code:
<hibernate-mapping schema="mavje">
<class name="Foo" table="foo" lazy="true">
<composite-id name="id" class="Foo$Id">
<key-property name="p" column="P"/>
<key-property name="u" column="U"/>
</composite-id>
<property name="s" column="S"/>
</class>
</hibernate-mapping>
<hibernate-mapping schema="mavje">
<class name="Bar" table="bar" lazy="true">
<composite-id name="id" class="Bar$Id">
<key-property name="p" column="P"/>
<key-property name="s" column="S"/>
<key-property name="l" column="L"/>
</composite-id>
</class>
</hibernate-mapping>
Now to the problem!!!
How do I map the barList in the class Foo?
It's straight forward if I was using the primary key from Foo to build the barList, but in my case I need a property from the combined primarykey and a normal property.
Any ideas???
Mads