Solved

Hibernate Sequence generation for id using oracle sequence object

Posted on 2011-09-27
1
793 Views
Last Modified: 2013-11-15

I have used the following annotation for id generation from oracle sequence object using hibernate

@Column(name = "USER_ID", unique = true,nullable = false)
    @Basic(fetch = FetchType.EAGER)
    @Id @GeneratedValue(generator = "seq_gen")
    @org.hibernate.annotations.GenericGenerator(
        name = "seq_gen",
        strategy = "sequence",
        parameters = @org.hibernate.annotations.Parameter(name = "property", value = "USR_SEQ")
    )

also
used
 instead of GenericGenerator
@SequenceGenerator(name = "seq_gen", sequenceName = "USR_SEQ", allocationSize = 1)

but still oracle sequence object "USR_SEQ" is not used for sequence generation.

 I want the id to be generated using oracle sequence object instead of hibernate hilo generator.

oracle sequence object is:
CREATE SEQUENCE FIBATDBO.USERS_SEQ INCREMENT BY 1 MAXVALUE 999999999999999999999999999 MINVALUE 1 CACHE 20


Please advice.
0
Comment
Question by:bhask12
1 Comment
 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
ID: 36714831
You have to name the sequence on the mapping according the tool you use like:

<generator class="sequence">
    <param name="sequence"> USERS_SEQ </param>
</generator>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now