-->
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: how to add id field to table holding just a list of Strings
PostPosted: Fri Apr 07, 2006 4:11 am 
Newbie

Joined: Fri Apr 07, 2006 4:00 am
Posts: 1
how to add id field to table holding just a list of Strings?

This is my hbm.xml
<list name="versionList" table="versionList" cascade="all" >
<key column="parentComponent_id" />
<list-index column="parentComponentOrder" />
<element column="version" type="java.lang.String" />
</list>

this creates versionList table with three columns: parentComponent_id , parentComponentOrder and version.
Apart from this I want to add unique id generator field to the table.

Hibernate 1 had some feature as specified in http://www.xylax.net/hibernate/toplevel.html

How to do in hibernate 3?

Thanks,
Hari Sujathan


Top
 Profile  
 
 Post subject: Is this what you are asking about?
PostPosted: Fri Apr 07, 2006 4:34 pm 
Newbie

Joined: Thu Apr 06, 2006 6:06 pm
Posts: 10
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="mySystem.valueObject">
<class name="mySystem.valueObject.PriorityVO"
table="PRIORITY">
<id name="idPriority" type="java.lang.String"
column="IDPRIORITY">
<generator class="assigned"/>
</id>

<property name="bobsPriority" type="java.lang.String"
column="BOBS_PRIORITY" length="1"/>
<property name="Standard" type="java.lang.String"
column="STANDARD"/>
<property name="missingPri" type="java.lang.String"
column="MISSING_PRIORITY"/>

</class>
</hibernate-mapping>

In this example the String idPriority is the primary key. It is labeled "assigned" meaning that the java code will generate it. That makes this table a table of strings with one string randomly selected to be the id. In your table, you would make it the primary key.
Hope this helps


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.