Example usage for org.hibernate.mapping Table getOrCreateIndex

List of usage examples for org.hibernate.mapping Table getOrCreateIndex

Introduction

In this page you can find the example usage for org.hibernate.mapping Table getOrCreateIndex.

Prototype

public Index getOrCreateIndex(String indexName) 

Source Link

Usage

From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java

License:Apache License

protected void bindIndex(String columnName, Column column, ColumnConfig cc, Table table) {
    if (cc == null) {
        return;//from ww  w.jav  a 2  s.c o  m
    }

    Object indexObj = cc.getIndex();
    String indexDefinition = null;
    if (indexObj instanceof Boolean) {
        Boolean b = (Boolean) indexObj;
        if (b) {
            indexDefinition = columnName + "_idx";
        }
    } else if (indexObj != null) {
        indexDefinition = indexObj.toString();
    }
    if (indexDefinition == null) {
        return;
    }

    String[] tokens = indexDefinition.split(",");
    for (int i = 0; i < tokens.length; i++) {
        String index = tokens[i];
        table.getOrCreateIndex(index).addColumn(column);
    }
}

From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java

License:Apache License

private static void bindIndex(String columnName, Column column, ColumnConfig cc, Table table) {
    if (cc == null) {
        return;/*from   w  ww.j  a v  a2s.c om*/
    }

    Object indexObj = cc.getIndex();
    String indexDefinition = null;
    if (indexObj instanceof Boolean) {
        Boolean b = (Boolean) indexObj;
        if (b) {
            indexDefinition = columnName + "_idx";
        }
    } else if (indexObj != null) {
        indexDefinition = indexObj.toString();
    }
    if (indexDefinition == null) {
        return;
    }

    String[] tokens = indexDefinition.split(",");
    for (int i = 0; i < tokens.length; i++) {
        String index = tokens[i];
        table.getOrCreateIndex(index).addColumn(column);
    }
}

From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java

License:Apache License

protected void bindIndex(String columnName, Column column, ColumnConfig cc, Table table) {
    if (cc == null) {
        return;//from   www  .j a  va2s .  c om
    }

    Object indexObj = cc.getIndex();
    String indexDefinition = null;
    if (indexObj instanceof Boolean) {
        Boolean b = (Boolean) indexObj;
        if (b) {
            indexDefinition = table.getName() + '_' + columnName + "_idx";
        }
    } else if (indexObj != null) {
        indexDefinition = indexObj.toString();
    }
    if (indexDefinition == null) {
        return;
    }

    String[] tokens = indexDefinition.split(",");
    for (int i = 0; i < tokens.length; i++) {
        String index = tokens[i];
        table.getOrCreateIndex(index).addColumn(column);
    }
}