Hello,
I'm working on a project and use hibernate tools (Hibernate 3.0 XML Editor) to generate the entities. I need it to let me use an existing database in my JEE java code.
I want to add a mapping/list/bag to an entity which contains address info. The simplified database tables looks like this:
Contact --------------- contactcode (PK) contacttype (PK) lastname firstname dateofbirth ....
Address -------------- contactcode (PK) contacttype (PK) index (PK) addressrow
In the database there isnt a FK relation defined, but as you can see this construction allows to add any number of address rows to a contact. What I want to acomplish is that the contact entity I use in my code contains a address property (as a list or collection) which contains all the address rows. Use SQL you can get the info with an extra select but how do I model this in the hbm.xml?
I tried some things in the contact.hbm.xml file but nothing worked. I did read a lot of documents but cant find an example which matches my situation.
b.t.w. I'm using exclipse with hibernate and hibernate tools.
Anyone got a suggestion ?
|