-->
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: O/R Mapping a class with NO ID??
PostPosted: Mon Jul 19, 2004 4:38 pm 
Beginner
Beginner

Joined: Thu May 20, 2004 3:40 pm
Posts: 33
How can I create a simple class/hbm.xml file that DOES NOT have an ID. I thought the name attribute was optional: If the name attribute is missing, it is assumed that the class has no identifier property.

I just want to have a table with NO ID:

Example:

create table LOCAL_HISTORY_TB (
val_c VARCHAR(512) not null,
iso_code_c CHAR(2),
)


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

<hibernate-mapping schema="refsdev" >

<class name="com.gs.fw.gc.core.refs.HistoryTB" table="HISTORY_TB">

<id>
<generator class="assigned"/>
</id>

<property name="val" column="val_c" length="512" not-null="true"/>
<property name="isoCode" column="iso_code_c" length="2" not-null="false"/>

</class>

</hibernate-mapping>

Thanks!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 4:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Mapping a table without a primary key is impossible. You can map a class without an id property, but you always have to map a primary key.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 19, 2004 4:52 pm 
Beginner
Beginner

Joined: Thu May 20, 2004 3:40 pm
Posts: 33
THANKS FOR THE QUICK RESPONSE!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 7:54 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You could map all properties as a composite key.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.