-->
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: Use Composite-id with Hibernate3
PostPosted: Mon May 28, 2007 9:02 am 
Newbie

Joined: Mon May 28, 2007 2:25 am
Posts: 9
In My Project Database We are creating the CompositeID as

This is my hbm.xml File:


<hibernate-mapping>
<class name="com.myComy.test.TbAddress" table="tb_address">
<composite-id name="id"class="com.myComy.test.TbAddressId">
<key-property name="addId" type="java.lang.Integer">
<column name="addID" />
</key-property>
<key-property name="address" type="java.lang.String">
<column name="Address" />
</key-property>
<key-property name="addressIndex" type="java.lang.Integer">
<column name="address_index" />
</key-property>
<key-property name="userId" type="java.lang.Integer">
<column name="userId" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>


Actually i am new in Hibernate ......

How we can perform CRUD(Insert,Delete,update,select) Opeartion in Composite-id ?

Can you pls give me the Sample code for the Same.

Thnaks,
Ashish


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

Hibernate version:

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:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject: Use Composite-id with Hibernate3
PostPosted: Mon May 28, 2007 10:44 am 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
Hello, i suggest you to use a simpler id. But to answer you question you should create an instance of com.myComy.test.TbAddressId for each CRUD operation, it's kinda the same as a single id, when looking by the id you should look for each of the fields declared in the id.

Hope this help you, if you got anymore questions feel free to ask, and remember to rate the post, if it help to find what you're lookin' for.

Regards,


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.