-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Many-toMany
PostPosted: Mon Mar 13, 2006 9:16 am 
Newbie

Joined: Tue Mar 07, 2006 8:31 am
Posts: 7
Hibernate Tools 3.1 beta 4
Eclipse SDK 3.1.2
PostgreSQL 8.1

Hi all again!

I am very new in hibernate and java, and i would appreciate some help or example that someone have.

I have a simple many-to-many association! Like Person and Equipment and we create a Person_Equipment table with two PKs like PersonID and EquipmentID.

Code:
CREATE TABLE person (
id int8 CONSTRAINT PK_person_id PRIMARY KEY,
firstname varchar(50),
surname varchar(50)
)
WITHOUT OIDS

CREATE TABLE equipment (
id int8 CONSTRAINT PK_equipment_id PRIMARY KEY,
title varchar(50),
description varchar(500)
)
WITHOUT OIDS

CREATE TABLE person_equipment (
person_id int8,
equipment_id int8,
CONSTRAINT FK_person_id FOREIGN KEY (person_id) REFERENCES person (id),
CONSTRAINT FK_equipment_id FOREIGN KEY (equipment_id) REFERENCES equipment (id)
)
WITHOUT OIDS


The Hibernate tool creates 3 mapping files for person, equipment and person_equipment and 3 POJO-Classes. I need only two POJO classes with association HashSets between person and equipment.

How can i create the mapping file and POJO for this situation?

Thanks,
Eugene Lechner


Top
 Profile  
 
 Post subject: Re: Hibernate Many-toMany
PostPosted: Mon Mar 13, 2006 10:30 am 
Regular
Regular

Joined: Wed Feb 22, 2006 11:28 am
Posts: 65
Location: Santiago, Chile
Hello Friend:

You can see the sample in Hibernate Reference Documentation:

Events - Persons.

That will indicate to you how to do it right.

Go to see it, and that whill help you a lot.

Request for comments

Naketsu Shonen


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.