-->
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: Oracle Sequences
PostPosted: Wed Aug 09, 2006 12:00 pm 
Newbie

Joined: Wed Aug 09, 2006 11:56 am
Posts: 1
I have a general question about hibernate 3 with annotations and oracle sequences.

Is it possible to create a sequence using hibernate 3 annotations? I can't seem to find any documentation or examples on this, so if it is possible, would someone please be so kind as to point me in the right direction.

Thanks,
jason


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 12:35 pm 
Newbie

Joined: Thu Nov 10, 2005 7:21 pm
Posts: 4
Location: Germany
Hi there,

what about this:
Code:
@Table(name="TAB1")
public class Table ... {
    ...
    @Id
    @GeneratedValue(generator = "hibseq")
    @GenericGenerator(name = "hibseq", strategy = "sequence", parameters = { @Parameter(name = "sequence", value = "SEQ_TAB1") })
    public Long getId() {
        return this.id;
    }


Kind regards
Karl Heinz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 25, 2006 8:04 am 
Newbie

Joined: Wed Aug 23, 2006 7:59 am
Posts: 7
You simply annotate the class like this:

Code:
@SequenceGenerator(
        name="SEQ_PDA",
        sequenceName="res_rpa_seq"
)


then make your id field something like this:
Code:
    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_PDA")
    public Long getId() {
        return m_id;
    }


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.