-->
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: Need help with comosite-id mapping
PostPosted: Tue Apr 25, 2006 8:22 am 
Newbie

Joined: Fri Apr 21, 2006 2:39 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1
MySLQ version 3.4.1

I am using hibernate for our project.I am having a single class
public class sample{
int id ;
String name;
String userName;
boolean vaild;
// Zero argument constructor
//Getters ans setters
}

I need to make the combination of (id, name, userName, valid) as a unique key.
How can write my mapping hibernate.cfg.xml file ?

Thanks and regards,
Ary


Top
 Profile  
 
 Post subject: Re: Need help with composite-id mapping
PostPosted: Tue Apr 25, 2006 12:54 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping >
<class  name="sample" table="sample">
   <composite-id>
      <key-property name="id"/>
      <key-property name="name"/>
      <key-property name="userName"/>
      <key-property name="valid"/>
   </composite-id>
</class>
</hibernate-mapping>


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.