hibernate problem

O

Omega

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
 
A

Adam Maass

Omega said:
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>?

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>
 
O

Omega

Adam said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top