-->
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.  [ 4 posts ] 
Author Message
 Post subject: how to use sequence in postgresql
PostPosted: Sat Jan 17, 2009 7:04 am 
Newbie

Joined: Tue Jan 06, 2009 9:29 am
Posts: 2
hello

i facing a strange problem in my code.. first little bit explain my DB

i have Postgres DB in which have table Client,..
Client atble have fields like
clientID *sequence
ClientName *Filed
ClientEmail *Primary Key


now in hibernate i want to assign the generator name in the field ClientID

i using in Annotation fr mapping

bt when i do that


@Entity
@javax.persistence.SequenceGenerator(
name="SEQ_Client",
sequenceName="client_clientid_seq",
allocationSize=1)

@Table(name="client")
public class Client implements Serializable,Comparable<Client>{

@Id
private String businessname;

@Column(name="clientid")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_Client")
private Integer clientid;




but it not taking the sequence Generator on the Filed wheich is not a primary Key and not increment the value when i try to save data in Client table...

so help me out how i can set the Sequence Genrator on simple Filed in hibernate

waiting fr response....


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 7:07 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
u may use sequence generator along with triger.

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 7:09 am 
Newbie

Joined: Tue Jan 06, 2009 9:29 am
Posts: 2
show me some example plz...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 17, 2009 7:10 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
<id name="id" type="java.lang.String">
<column name="mailid" />
<generator class="sequence">
<param name="sequence"> email_seq</param>
</generator>

</id>

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.