Solved

Hibernate Sequence generation for id using oracle sequence object

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle SQL - Query help 7 66
run sql script from putty 4 67
SYS password changed. Now can't log in as SYS 27 28
Loading flat file data in tables 2 40
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
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…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

856 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