-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping definition for table with no primary key
PostPosted: Fri Mar 10, 2006 10:08 am 
Newbie

Joined: Thu Mar 09, 2006 5:39 pm
Posts: 7
Hi,

I am new to Hibernate. I need to map a Class Object with a table, the table has no primary keys. How should be its mapping defined in this case.

thanks
jitender


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 10:39 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
make every field part of the primary key for hibernate, or add a surrogate primary key to the table

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 11:08 am 
Newbie

Joined: Thu Mar 09, 2006 5:39 pm
Posts: 7
Can you pls give an example mapping for same.

thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 10, 2006 11:49 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Code:
<class
    name="package.Class"
    table="some_table"
>

    <composite-id name="comp_id" class="package.package.ClassPK">
        <key-property
            name="stuMastNo"
            column="stu_mast_no"
            type="java.lang.Integer"
        />
        <key-property
            name="sourceId"
            column="source_id"
            type="java.lang.String"
            length="8"
        />
        <key-property
            name="sourceCd"
            column="source_cd"
            type="java.lang.String"
            length="3"
        />
       
    </composite-id>

</class>

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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