-->
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.  [ 1 post ] 
Author Message
 Post subject: Using @GeneratedValue annotation on a non-id column.
PostPosted: Mon Sep 20, 2010 8:55 am 
Newbie

Joined: Mon Sep 14, 2009 3:49 pm
Posts: 1
Hello,

I would like to use a @GeneratedValue annotations on a non-id column, is that possible?

The annotation is also used on the id :

@Id @GeneratedValue(generator="naid-uuid") @GenericGenerator(name="naid-uuid", strategy="com.netappsid.erp.UUIDGenerator") @Type(type="com.netappsid.datatypes.UUIDUserType")
@AccessType(value="field")
public Serializable getId()
{
return id;
}


This is the field I'd like to auto-increment.

@Column(name = "identifier", insertable = false, updatable = false)
@Generated(value=GenerationTime.INSERT)
@GeneratedValue(strategy=GenerationType.IDENTITY)
@AccessType(value="field")
public Long getIdentifier()
{
return identifier;
}

In PostgreSQL this column will be an int8 instead of a bigserial.
In SQL Server this column will be a numeric (19,0) without identity
(Using hibernate 3.3.2)

Thank you in advance,

Ghislain


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.