I'm trying to use a defined sequence generation in Oracle JPA, along with GenerationType.AUTO like this:
@Id
@SequenceGenerator(name = "MY_GEN_NAME", sequenceName = "MY_SQ_NAME")
@GeneratedValue(strategy = GenerationType.AUTO, generator = "MY_GEN_NAME")
@Column(name = "ID", nullable = false)
private Long id;
After running the hibernate validation it throws an error:
Schema validation: missing sequence [hibernate_sequence]
I guess, it is ignoring my MY_GEN_NAME and trying to use that global sequence for id generation.
When I switch to GenerationType.SEQUENCE, it uses SequenceHiLoGenerator and it works fine.
Why is that happening, and is it possible to make the GenerationType.AUTO work with given sequence for Oracle (possibility to switch to other db)?
GenerationType.AUTO. Let's say I have read only Oracle DB where sequences are created, but in the implementation I have to be ready to switch for MySQL (thats whyAUTO, and notSEQUENCE). However when I'm usingAUTO- even when I tell JPA what sequence to use, it still looks for or tries to create that globalhibernate_sequence. - patrykos91