?
Solved

Hibernate Sequence generation for id using oracle sequence object

Posted on 2011-09-27
1
Medium Priority
?
834 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
schwertner earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Invest in your employees with these five simple steps to improve employee engagement and retention.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

770 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