Why does Hibernate 5 sequence generator use the default hibernate.seq instead of my sequence?
Asked Answered
A

2

5

Aftre migrate my application from hibernate 4 to hibernate 5 .my sequence dose not work and hibernate use our default sequence instead of my sequence .my mapping config in hbm like this my database is oracle .

<id name="id"  column="Id" type="java.lang.Long">
    <generator class="sequence" >
            <param name="sequence">SEQ_APP_Login_Log</param>   
    </generator>
</id>

after google some people say change class to org.hibernate.id.enhanced.SequenceStyleGenerator but dose not work again.

Acclamation answered 12/2, 2017 at 18:3 Comment(0)
C
12

It's simple. The sequence attribute has changed to sequence_name:

<id name="id" column="Id" type="java.lang.Long">
    <generator class="sequence" >
            <param name="sequence_name">SEQ_APP_Login_Log</param>   
    </generator>
</id>
Crotty answered 12/2, 2017 at 18:25 Comment(1)
how can i using sequence_name in both hibernate 4 and 5 ,I have framework that use in more than 10 Enterprise App . i want to migrate to hibernate 5 and change this hbm but i want my framework work in both versionAcclamation
S
0

class "sequence" is shortcut for "org.hibernate.id.SequenceGenerator" which is deprecated. use the following for hibernate5+:

<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
    <param name="optimizer">none</param>
    <param name="increment_size">1</param>
    <param name="sequence_name">MY_SEQUENCE</param>
</generator>
Sianna answered 6/8, 2023 at 20:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.