Create @GeneratedValue sequence in hibernate and liquibase

Viewed 123

In liquibase I added a script for creating a database and also use in Java / Spring Entity with GeneratedValue and my SequenceGenerator. In the case of the script in liquibase, do I have to add the generation of the identifier with the sequence to it, or is it enough that I have it from the level of my entity?

    @SequenceGenerator(name = "TEST_DATA_SEQ", sequenceName = "TEST_DATA", initialValue = 1, allocationSize = 1)
public class TestPPData {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TEST_DATA_SEQ")
    @Column(name = "ID", nullable = false)
    private Long id;
CREATE TABLE TEST_DATA
(
    ID          NUMBER(10) PRIMARY KEY,
 ....
);

COMMENT ON COLUMN TEST_DATA.ID IS 'Primary key';

And my LB

- changeSet:
      id: test
      author: test
      changes:
        - sqlFile:
            dbms: oracle
            encoding: utf8
            path: scripts/test.sql
            relativeToChangelogFile: true
            splitStatements: true
        stripComments: false

or I must need add ?

createSequence:
incrementBy: 1
sequenceName: TEST_DATA_SEQ
startValue: 1
0 Answers
Related