Example usage for org.hibernate.mapping PrimaryKey sqlConstraintString

List of usage examples for org.hibernate.mapping PrimaryKey sqlConstraintString

Introduction

In this page you can find the example usage for org.hibernate.mapping PrimaryKey sqlConstraintString.

Prototype

public String sqlConstraintString(Dialect dialect) 

Source Link

Usage

From source file:net.lshift.hibernate.migrations.AlterTableBuilder.java

License:Apache License

public AlterTableBuilder addPrimaryKey(String... cols) {
    PrimaryKey pk = new PrimaryKey();
    for (String col : cols) {
        pk.addColumn(new Column(col));
    }// w w w  .j  a  va  2  s .  c o m
    alterFragments.add("add " + pk.sqlConstraintString(dialect));
    return this;
}

From source file:net.lshift.hibernate.migrations.AlterTableBuilder.java

License:Apache License

public AlterTableBuilder replacePrimaryKey(String... cols) {
    PrimaryKey pk = new PrimaryKey();
    for (String col : cols) {
        pk.addColumn(new Column(col));
    }//  www  .j av  a  2 s.  c o  m
    if (dialectExtension.supportsPrimaryKeyReplace()) {
        alterFragments.add("drop primary key, add " + pk.sqlConstraintString(dialect));
    } else {
        dropPrimaryKey().addPrimaryKey(cols);
    }
    return this;
}