devang
devang

Reputation: 5516

Liquibase: Using sequence

I am using the InsertStatement class and I want to pass the sequence generation code. How do I do that? I tried following, but did not work.

InsertStatement statement1 = new InsertStatement("saas", "OAuth2AppTemplate");
statement1.addColumnValue("id", 
    new SelectSequencesStatement("saas.seq.nextval"));

Any inputs?

Upvotes: 2

Views: 1013

Answers (1)

devang
devang

Reputation: 5516

Okay, after lot of digging into the Liquibase documentation I found it.

InsertStatement statement1 = new InsertStatement("saas", "OAuth2AppTemplate");
final Sequence sequence = new Sequence();
sequence.setName("saas.OAuth2AppTemplate_id_seq.nextval");
statement1.addColumnValue("id", sequence);

And this then generates the query appropriately.

Upvotes: 3

Related Questions