Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

hibernate problem

Thread view: 
Omega - 21 Apr 2006 14:37 GMT
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
Adam Maass - 21 Apr 2006 15:38 GMT
>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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.