-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping problem
PostPosted: Wed May 16, 2007 9:24 am 
Beginner
Beginner

Joined: Wed Nov 08, 2006 8:24 am
Posts: 26
Location: Gothenburg, Sweden
I'm 'hibernating' a legacy database and have run into a problem. How do I map a table with a primary key that consist of two columns?

The table is defined as:
Code:
CREATE TABLE "BUSPGM"
(
  "BUSID"    IDNUMBER  NOT NULL,
  "PGMID"    IDNUMBER  NOT NULL,
  "PGMTYPE"    PROGRAMTYPES  NOT NULL,
UNIQUE ("PGMID"),
CONSTRAINT "PKEY_BUSPGM" PRIMARY KEY ("BUSID", "PGMID")
);


I made a workaround for this table, using the pgmid column as a primary key in the mapping file. But I have several other tables with the same problem.


Top
 Profile  
 
 Post subject: Re: Mapping problem
PostPosted: Wed May 16, 2007 11:23 am 
Newbie

Joined: Wed May 16, 2007 6:16 am
Posts: 3
I think what you are looking for is composite-id :

Code:
<class name="eg.Foo" table"FOOS">
    <composite-id name="compId" class="eg.FooCompositeID">
        <key-property name="string"/>
        <key-property name="short"/>
        <key-property name="date" column="date_" type="date"/>
    </composite-id>
    <property name="name"/>
    ....
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 10:23 am 
Beginner
Beginner

Joined: Wed Nov 08, 2006 8:24 am
Posts: 26
Location: Gothenburg, Sweden
Thanks, that did it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.