-->
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: Primary key settings
PostPosted: Mon Jul 07, 2008 9:21 am 
Newbie

Joined: Mon Jun 30, 2008 8:28 am
Posts: 2
Dear All,
i want to set the even no primary key in my project.like 2,4,6,8...
which method shall i use like increment,sequence...
please help me with mapping file settings and sample code.


regards,
arul
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 3:13 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You could always use a Sequence?

Image

There are really three separate generation types you have access to: identity, sequence and table.

You might also want to experiment with the GeneratedValue setting for the TableGeneration:

Code:
@Id
@TableGenerator(name="tg", table="pk_table",
    pkColumnName="name", valueColumnName="value",
                                     allocationSize=10
)@GeneratedValue(strategy=GenerationType.TABLE, generator="tg")
public long getId() {return id;}


http://jpa.ezhibernate.com/Javacode/lea ... jpamapping

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.