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
PostPosted: Wed Oct 20, 2004 5:40 pm 
Newbie

Joined: Wed Oct 20, 2004 5:27 pm
Posts: 1
Description :
i want to know how can we write a component with composite-id, for example the following documents mapping...
[b]Hibernate version:

2.1.6
Mapping documents:
Bar.hbm.xml :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="filters">

<class name="test.Bar" table="BAR">

<composite-id>
<key-property name="nom" column="nom" type="int" />
<key-property name="prenom" column="prenom" type="int" />
<key-many-to-one name="id" class="test.Foo" column="CODE_FOO"/>
</composite-id>
<property name="email" type="string" column="email" />
</class>

</hibernate-mapping>

Foo.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="filters">

<class name="test.Foo" table="Foo">
<id
name="id"
type="int"
column="CODE_FOO">
<generator class="native"/>
</id>
<property
name="nom"
column="NAME"
type="string"
/>

</class>

</hibernate-mapping>

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

Full stack trace of any exception that occurs:
Buildfile: C:\java\eclipse\workspace\test\build.xml
codegen:
[hbm2java] Processing 2 files.
[hbm2java] Building hibernate objects
[hbm2java] 21:25:13,484 WARN BasicRenderer:404 - No properties has been marked as being used in equals/hashcode for Bar. Using object identifier which is RARELY safe to use! See http://hibernate.org/109.html
BUILD SUCCESSFUL
Total time: 1 second
Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 20, 2004 7:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Check the docs:
http://www.hibernate.org/hib_docs/reference/en/html/toolsetguide.html#toolsetguide-s2

The warning is telling you to use HBM meta tags to indicate the properties that should be used in the equals and hashcode methods that are required to be generated. See tag implement-equals and use-in-equals.


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.