Solved

Hibernate Sequence generation for id using oracle sequence object

Posted on 2011-09-27
1
787 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
This video shows how to recover a database from a user managed backup
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

747 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