I have a problem with Hibernate.
Lets say I have class A, BList and B. They look like this:
class A {
private long id;
private BList list;
get/setXXX();
otherMethods();
}
class BList {
private ArrayList<B> bList;
add/remove/etc.
}
class B {
some private fields;
}
I would like to transfer those classes into database with two relations: As
and Bs, and Bs would have a foreign key to class A. How can I do that using
hibernate? Should I use <nested-composite-element>?
Thanks in advance
Omega
>I have a problem with Hibernate.
> Lets say I have class A, BList and B. They look like this:
[quoted text clipped - 26 lines]
> using
> hibernate? Should I use <nested-composite-element>?
RTFM: http://www.hibernate.org/hib_docs/v3/reference/en/html/
Given this sketch of the problem, I'm having a hard time seeing what you're
gaining by the class BList. Eliminate it, and your mapping problem becomes
basically canonical:
class A {
private Long id;
Set<B> bs;
}
class B {
}
<class name="A" table="A">
....
<set name="bs" table="B">
<key column="A_FK">
<composite-element class="B">
....
</composite-element>
</set>
....
</class>
Omega - 21 Apr 2006 16:42 GMT
> RTFM: http://www.hibernate.org/hib_docs/v3/reference/en/html/
> Given this sketch of the problem, I'm having a hard time seeing what
> you're gaining by the class BList. Eliminate it, and your mapping
> problem becomes basically canonical:
I know it would be easiest to change the model, but it is a given, it is
rather large and it would be defficult to change it know. Is it any way to
transfer it without changing the model?
Omega