-->
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: Very basic question
PostPosted: Mon May 09, 2005 5:44 pm 
Newbie

Joined: Mon May 09, 2005 5:24 pm
Posts: 1
I have just started working with Hibernate. I have a table called Candidate in a database in which the field ORIGINAL_ID is the primary key. ORIGINAL_ID is of type VARCHAR2. I already have a POJO in a class called test.Candidate. The property 'fid' in this class corresponds to the field ORIGINAL_ID in the table.

I am in the process of writing a mapping file pertaining to the Candidate table. If I want to map it to a POJO then my mapping would look like:

<hibernate-mapping>
<class name="test.Candidate" table="Candidate">
<id name="fid" type="string" unsaved-value="null" >
<column name="ORIGINAL_ID" sql-type="varchar2(15)" not-null="true"/>
<generator class="?????"/>
</id>
.
.
. <<other-stuff>>
</hibernate-mapping>

My question is what should be put in place of the ????? for the generator class. I guess I could use any of the built-in implementations of the IdentifierGenerator interface. However, my confusion stems from the fact that it seems that the generated id should map to some column in the database. I want to make the ORIGINAL_ID column be the place from which Hibernate can draw the unique generated id. However, most of the built-in generators can produce long, short or int for the id. So I cannot except such generators to use ORIGINAL_ID.

What should be my approach to handle such a problem?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 3:20 am 
Beginner
Beginner

Joined: Fri Feb 11, 2005 12:03 pm
Posts: 48
Location: Kiel, Germany
See
http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-id

You can implement your own generator class or you can use the builtin generators uuid.hex, uuid.string which produce string identifiers,


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.