Example usage for org.hibernate.cfg NamingStrategy tableName

List of usage examples for org.hibernate.cfg NamingStrategy tableName

Introduction

In this page you can find the example usage for org.hibernate.cfg NamingStrategy tableName.

Prototype

public String tableName(String tableName);

Source Link

Document

Alter the table name given in the mapping document

Usage

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

License:Apache License

protected void bindCollectionTable(GrailsDomainClassProperty property, Mappings mappings, Collection collection,
        Table ownerTable, String sessionFactoryBeanName) {

    String owningTableSchema = ownerTable.getSchema();
    PropertyConfig config = getPropertyConfig(property);
    JoinTable jt = config != null ? config.getJoinTable() : null;

    NamingStrategy namingStrategy = getNamingStrategy(sessionFactoryBeanName);
    String tableName = (jt != null && jt.getName() != null ? jt.getName()
            : namingStrategy.tableName(calculateTableForMany(property, sessionFactoryBeanName)));
    String schemaName = mappings.getSchemaName();
    String catalogName = mappings.getCatalogName();
    if (jt != null) {
        if (jt.getSchema() != null) {
            schemaName = jt.getSchema();
        }/*w  w w  .  j  a v a 2 s. c  om*/
        if (jt.getCatalog() != null) {
            catalogName = jt.getCatalog();
        }
    }

    if (schemaName == null && owningTableSchema != null) {
        schemaName = owningTableSchema;
    }

    collection.setCollectionTable(mappings.addTable(schemaName, catalogName, tableName, null, false));
}

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

License:Apache License

protected void bindCollectionTable(ToMany property, Mappings mappings, Collection collection, Table ownerTable,
        String sessionFactoryBeanName) {

    String owningTableSchema = ownerTable.getSchema();
    PropertyConfig config = getPropertyConfig(property);
    JoinTable jt = config != null ? config.getJoinTable() : null;

    NamingStrategy namingStrategy = getNamingStrategy(sessionFactoryBeanName);
    String tableName = (jt != null && jt.getName() != null ? jt.getName()
            : namingStrategy.tableName(calculateTableForMany(property, sessionFactoryBeanName)));
    String schemaName = mappings.getSchemaName();
    String catalogName = mappings.getCatalogName();
    if (jt != null) {
        if (jt.getSchema() != null) {
            schemaName = jt.getSchema();
        }//from  w  ww  .  ja v a  2s . c  o m
        if (jt.getCatalog() != null) {
            catalogName = jt.getCatalog();
        }
    }

    if (schemaName == null && owningTableSchema != null) {
        schemaName = owningTableSchema;
    }

    collection.setCollectionTable(mappings.addTable(schemaName, catalogName, tableName, null, false));
}

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

License:Apache License

protected void bindCollectionTable(ToMany property, InFlightMetadataCollector mappings, Collection collection,
        Table ownerTable, String sessionFactoryBeanName) {

    String owningTableSchema = ownerTable.getSchema();
    PropertyConfig config = getPropertyConfig(property);
    JoinTable jt = config != null ? config.getJoinTable() : null;

    NamingStrategy namingStrategy = getNamingStrategy(sessionFactoryBeanName);
    String tableName = (jt != null && jt.getName() != null ? jt.getName()
            : namingStrategy.tableName(calculateTableForMany(property, sessionFactoryBeanName)));
    String schemaName = getSchemaName(mappings);
    String catalogName = getCatalogName(mappings);
    if (jt != null) {
        if (jt.getSchema() != null) {
            schemaName = jt.getSchema();
        }//from  w ww.  ja  v a  2 s  .  c om
        if (jt.getCatalog() != null) {
            catalogName = jt.getCatalog();
        }
    }

    if (schemaName == null && owningTableSchema != null) {
        schemaName = owningTableSchema;
    }

    collection.setCollectionTable(mappings.addTable(schemaName, catalogName, tableName, null, false));
}

From source file:org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaColumnImpl.java

License:Open Source License

public String getSpecifiedDBTableName() {
    if (getSpecifiedTableName() == null)
        return null;
    NamingStrategy ns = getJpaProject().getNamingStrategy();
    if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
        try {//from  ww  w . ja v a  2 s .  c om
            return ns.tableName(getSpecifiedTableName());
        } catch (Exception e) {
            IMessage m = HibernateJpaValidationMessage.buildMessage(IMessage.HIGH_SEVERITY,
                    Messages.NAMING_STRATEGY_EXCEPTION, this);
            HibernateJptPlugin.logException(m.getText(), e);
        }
    }
    return this.getSpecifiedTableName();
}

From source file:org.jboss.tools.hibernate.jpt.core.internal.context.java.HibernateJavaJoinTableImpl.java

License:Open Source License

@Override
public String getSpecifiedDBTableName() {
    if (getSpecifiedName() == null)
        return null;
    NamingStrategy ns = getJpaProject().getNamingStrategy();
    if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
        try {/*w w  w . j  a  va  2s  . c  o m*/
            return ns.tableName(getSpecifiedName());
        } catch (Exception e) {
            IMessage m = HibernateJpaValidationMessage.buildMessage(IMessage.HIGH_SEVERITY,
                    Messages.NAMING_STRATEGY_EXCEPTION, this);
            HibernateJptPlugin.logException(m.getText(), e);
        }
    }
    return this.getName();
}

From source file:org.jboss.tools.hibernate.jpt.core.internal.context.orm.HibernateOrmColumnImpl.java

License:Open Source License

@Override
public String getSpecifiedDBTableName() {
    if (getSpecifiedTableName() == null)
        return null;
    NamingStrategy ns = getJpaProject().getNamingStrategy();
    if (getJpaProject().isNamingStrategyEnabled() && ns != null) {
        try {/*from www. j  a  va2 s  . c o m*/
            return ns.tableName(getSpecifiedTableName());
        } catch (Exception e) {
            IMessage m = HibernateJpaValidationMessage.buildMessage(IMessage.HIGH_SEVERITY,
                    Messages.NAMING_STRATEGY_EXCEPTION, this);
            HibernateJptPlugin.logException(m.getText(), e);
        }
    }
    return this.getSpecifiedTableName();
}