-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to write a class for generating an assigned id?
PostPosted: Thu Oct 06, 2005 2:36 am 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0.5

Name and version of the database you are using:MySql 4.1

Hi guys,

I m using org.apache.commons.lang.RandomStringUtils to generate id for a table.


<id
name="id"
column="category_id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-Category.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>



How should I write a class to put into the mapping document so that I don't don't to specifically called org.apache.commons.lang.RandomStringUtils everytime I insert a record.
TIA !!

best regards,
Mark


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 8:20 am 
Newbie

Joined: Wed May 25, 2005 10:37 am
Posts: 5
Write a class implementing the interface org.hibernate.id.IdentifierGenerator and specify that class in the id section of the mapping document.

Code:
<id ....>
<generator class="com.mygenerator.MyIdGenerator>
</id>


It's explained here http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-id-generator


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 9:50 pm 
Regular
Regular

Joined: Mon Aug 02, 2004 9:33 am
Posts: 69
is it recommend to write your own identifier instead of using hibernate built-in id generator??


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.