-->
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 generate non identifier column auto increment ?
PostPosted: Tue Apr 03, 2007 8:04 am 
Newbie

Joined: Tue Apr 03, 2007 6:37 am
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hello every body,
I'm new in hibernate and now I have a problem
I want to generate a non identifier column that hibernate increment it automatically and I use that incremented value later.

thanks lot,
Regards


Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 03, 2007 11:19 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
You could use custom SQL-INSERT for the persistent class something like below:

Code:
<class name="Person">
<id name="id">
<generator class="increment"/>
</id>
<property name="name" not-null="true"/>
<sql-insert>INSERT INTO PERSON (NAME, ID) VALUES ( UPPER(?), ? )</sql-insert>
<sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE ID=?</sql-update>
<sql-delete>DELETE FROM PERSON WHERE ID=?</sql-delete>
</class>

_________________
--------------
Don't forget to Rate the post


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 03, 2007 3:13 pm 
Newbie

Joined: Tue Apr 03, 2007 6:37 am
Posts: 2
Hi,
thanks for your attention but I want hibernate to increment an integer column automatically every time new object inserted vio hibernate annotations and this column is not table identifier.

when we want to define an id auto generation:

@Id @GeneratedValue(sterategy=GenerationType.Auto)
private int id;

but what about a non identifier column ???


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.