Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hibernate Sequence generation for id using oracle sequence object

Posted on 2011-09-27
1
Medium Priority
?
845 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
Curious about the latest ransomware attack? Check out our timeline of events surrounding the spread of this new virus along with tips on how to mitigate the damage.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 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