简体   繁体   中英

Hibernate cannot handle sequences with same name in differen schemas

After upgrading from 5.4.7 to 5.4.10 it looks like hibernate cannot handle two sequences with the same name in different db schemas anymore.

I have this entity

@Entity
@Table(name = "VM_LAUF_RICHTUNG", schema = "INFOP_FAHRPLAN")
public class VmLaufRichtung {

    public static final String VM_LAUF_RICHTUNG_TABLE = "INFOP_FAHRPLAN.VM_LAUF_RICHTUNG";


    @Id
    @Digits(integer = 15, fraction = 0)
    @SequenceGenerator(name = "InfopFahrplan.seqVmLaufRichtung", schema = "INFOP_FAHRPLAN", sequenceName = "SEQ_VM_LAUF_RICHTUNG")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "InfopFahrplan.seqVmLaufRichtung")
    @Column(name = ID)
    private Long id;
}

In an other schema, there's a sequence with a the same name SEQ_VM_LAUF_RICHTUNG . When my spring boot application starts I do get

Caused by: org.hibernate.MappingException: The increment size of the [SEQ_VM_LAUF_RICHTUNG] sequence is set to [50] in the entity mapping while the associated database sequence increment size is [1].

This happens because it's picking up the wrong sequence, which has an other imcrement size.

I tried to fix the problem by setting

spring.jpa.hibernate.use-new-id-generator-mappings=true

but that did not change anything.

With hibernate 5.4.7 everyhting is working fine.

Did I miss something or is this a hibernate bug after all?

It looks that this is indeed a hibernate bug: https://hibernate.atlassian.net/browse/HHH-13322

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM