-->
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: Collections using Multiple Tables
PostPosted: Wed Oct 13, 2004 4:20 pm 
Newbie

Joined: Wed Jul 28, 2004 6:13 pm
Posts: 12
Hibernate 2.1.6. This is going to be such a noob question and I apologize. I've been able to create sets/bags/maps in Hibernate with simple one-to-many type relationships. But what about a relationship as follows (I'll include MySQL create table SQL definitions to give you an idea):

Code:
create table tpp_contracts (
    id                 char(32) primary key,
    effectivedate      datetime,
    terminationdate    datetime
);

create table tpp_contacts (
    id                  char(32) primary key,
    contractid          char(32) references tpp_contracts(id),
    contactid           char(32) not null
);

create table contacts (
    id                  char(32) primary key,
    name                varchar(128) default '',
    title               varchar(128) default '',
    phonenumber         varchar(64)  default ''
);

The tpp_contacts table binds the tpp_contracts and contacts table.. thus allowing me to have contacts associated with a specific contract. Would this be considered a many-to-many association.. thus meaning I should read the docs on collections a little closer? Also.. since the tpp_contacts table simply defines the relationship of contacts to contracts, does it need the Hibernate "id" column?

Thanks

--------------------------------------------------
Hibernate version:
2.1.6

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MySQL 4.1.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 13, 2004 4:33 pm 
Newbie

Joined: Wed Jul 28, 2004 6:13 pm
Posts: 12
Bah - you can probably ignore this question. I see a many-to-many post right on the first page of the forums where someone is doing this exact same thing. Sorry for the useless post :) I'll check out that thread.

Thanks.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.