Example usage for org.hibernate.mapping PrimaryKey getName

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

Introduction

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

Prototype

public String getName() 

Source Link

Usage

From source file:com.xpn.xwiki.store.migration.hibernate.R40000XWIKI6990DataMigration.java

License:Open Source License

/**
 * Append a add primary key constraint command for the given table.
 *
 * @param sb append the result into this string builder
 * @param table the table name//from  w  ww .  j a v  a2s . c o m
 */
private void appendAddPrimaryKey(StringBuilder sb, Table table) {
    PrimaryKey pk = table.getPrimaryKey();
    String pkName = pk.getName();

    sb.append("    <addPrimaryKey tableName=\"").append(table.getName()).append("\"  columnNames=\"");

    @SuppressWarnings("unchecked")
    Iterator<Column> columns = pk.getColumnIterator();
    while (columns.hasNext()) {
        Column column = columns.next();
        sb.append(column.getName());
        if (columns.hasNext()) {
            sb.append(",");
        }
    }

    if (pkName != null) {
        sb.append("\"  constraintName=\"").append(pkName);
    }

    sb.append("\"/>\n");
}