Example usage for org.hibernate.mapping JoinedSubclass setTable

List of usage examples for org.hibernate.mapping JoinedSubclass setTable

Introduction

In this page you can find the example usage for org.hibernate.mapping JoinedSubclass setTable.

Prototype

public void setTable(Table table) 

Source Link

Usage

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

License:Apache License

/**
 * Binds a joined sub-class mapping using table-per-subclass
 *
 * @param sub            The Grails sub class
 * @param joinedSubclass The Hibernate Subclass object
 * @param mappings       The mappings Object
 * @param gormMapping    The GORM mapping object
 * @param sessionFactoryBeanName  the session factory bean name
 *//* w ww  . jav  a2  s. c o m*/
protected void bindJoinedSubClass(GrailsDomainClass sub, JoinedSubclass joinedSubclass, Mappings mappings,
        Mapping gormMapping, String sessionFactoryBeanName) {
    bindClass(sub, joinedSubclass, mappings);

    if (joinedSubclass.getEntityPersisterClass() == null) {
        joinedSubclass.getRootClass()
                .setEntityPersisterClass(getGroovyAwareJoinedSubclassEntityPersisterClass());
    }

    Table mytable = mappings.addTable(mappings.getSchemaName(), mappings.getCatalogName(),
            getJoinedSubClassTableName(sub, joinedSubclass, null, mappings, sessionFactoryBeanName), null,
            false);

    joinedSubclass.setTable(mytable);
    LOG.info("Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> "
            + joinedSubclass.getTable().getName());

    SimpleValue key = new DependantValue(mappings, mytable, joinedSubclass.getIdentifier());
    joinedSubclass.setKey(key);
    GrailsDomainClassProperty identifier = sub.getIdentifier();
    String columnName = getColumnNameForPropertyAndPath(identifier, EMPTY_PATH, null, sessionFactoryBeanName);
    bindSimpleValue(identifier.getType().getName(), key, false, columnName, mappings);

    joinedSubclass.createPrimaryKey();

    // properties
    createClassProperties(sub, joinedSubclass, mappings, sessionFactoryBeanName);
}

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

License:Apache License

/**
 * Binds a joined sub-class mapping using table-per-subclass
 *
 * @param sub            The Grails sub class
 * @param joinedSubclass The Hibernate Subclass object
 * @param mappings       The mappings Object
 * @param gormMapping    The GORM mapping object
 * @param sessionFactoryBeanName  the session factory bean name
 *///from w ww .  ja va 2 s .  c  om
private static void bindJoinedSubClass(GrailsDomainClass sub, JoinedSubclass joinedSubclass, Mappings mappings,
        @SuppressWarnings("unused") Mapping gormMapping, String sessionFactoryBeanName) {
    bindClass(sub, joinedSubclass, mappings);

    if (joinedSubclass.getEntityPersisterClass() == null) {
        joinedSubclass.getRootClass().setEntityPersisterClass(GroovyAwareJoinedSubclassEntityPersister.class);
    }

    Table mytable = mappings.addTable(mappings.getSchemaName(), mappings.getCatalogName(),
            getJoinedSubClassTableName(sub, joinedSubclass, null, mappings, sessionFactoryBeanName), null,
            false);

    joinedSubclass.setTable(mytable);
    LOG.info("Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> "
            + joinedSubclass.getTable().getName());

    SimpleValue key = new DependantValue(mappings, mytable, joinedSubclass.getIdentifier());
    joinedSubclass.setKey(key);
    GrailsDomainClassProperty identifier = sub.getIdentifier();
    String columnName = getColumnNameForPropertyAndPath(identifier, EMPTY_PATH, null, sessionFactoryBeanName);
    bindSimpleValue(identifier.getType().getName(), key, false, columnName, mappings);

    joinedSubclass.createPrimaryKey();

    // properties
    createClassProperties(sub, joinedSubclass, mappings, sessionFactoryBeanName);
}

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

License:Apache License

/**
 * Binds a joined sub-class mapping using table-per-subclass
 *
 * @param sub            The Grails sub class
 * @param joinedSubclass The Hibernate Subclass object
 * @param mappings       The mappings Object
 * @param gormMapping    The GORM mapping object
 * @param sessionFactoryBeanName  the session factory bean name
 *///from  www . j  a v  a 2  s. co  m
protected void bindJoinedSubClass(HibernatePersistentEntity sub, JoinedSubclass joinedSubclass,
        Mappings mappings, Mapping gormMapping, String sessionFactoryBeanName) {
    bindClass(sub, joinedSubclass, mappings);

    if (joinedSubclass.getEntityPersisterClass() == null) {
        joinedSubclass.getRootClass()
                .setEntityPersisterClass(getGroovyAwareJoinedSubclassEntityPersisterClass());
    }

    Table mytable = mappings.addTable(mappings.getSchemaName(), mappings.getCatalogName(),
            getJoinedSubClassTableName(sub, joinedSubclass, null, mappings, sessionFactoryBeanName), null,
            false);

    joinedSubclass.setTable(mytable);
    LOG.info("Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> "
            + joinedSubclass.getTable().getName());

    SimpleValue key = new DependantValue(mappings, mytable, joinedSubclass.getIdentifier());
    joinedSubclass.setKey(key);
    final PersistentProperty identifier = sub.getIdentity();
    String columnName = getColumnNameForPropertyAndPath(identifier, EMPTY_PATH, null, sessionFactoryBeanName);
    bindSimpleValue(identifier.getType().getName(), key, false, columnName, mappings);

    joinedSubclass.createPrimaryKey();

    // properties
    createClassProperties(sub, joinedSubclass, mappings, sessionFactoryBeanName);
}

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

License:Apache License

/**
 * Binds a joined sub-class mapping using table-per-subclass
 *
 * @param sub            The Grails sub class
 * @param joinedSubclass The Hibernate Subclass object
 * @param mappings       The mappings Object
 * @param gormMapping    The GORM mapping object
 * @param sessionFactoryBeanName  the session factory bean name
 *//*from www  .ja v  a  2  s  . c  o  m*/
protected void bindJoinedSubClass(HibernatePersistentEntity sub, JoinedSubclass joinedSubclass,
        InFlightMetadataCollector mappings, Mapping gormMapping, String sessionFactoryBeanName) {
    bindClass(sub, joinedSubclass, mappings);

    String schemaName = getSchemaName(mappings);
    String catalogName = getCatalogName(mappings);

    Table mytable = mappings.addTable(schemaName, catalogName,
            getJoinedSubClassTableName(sub, joinedSubclass, null, mappings, sessionFactoryBeanName), null,
            false);

    joinedSubclass.setTable(mytable);
    LOG.info("Mapping joined-subclass: " + joinedSubclass.getEntityName() + " -> "
            + joinedSubclass.getTable().getName());

    SimpleValue key = new DependantValue(mappings, mytable, joinedSubclass.getIdentifier());
    joinedSubclass.setKey(key);
    final PersistentProperty identifier = sub.getIdentity();
    String columnName = getColumnNameForPropertyAndPath(identifier, EMPTY_PATH, null, sessionFactoryBeanName);
    bindSimpleValue(identifier.getType().getName(), key, false, columnName, mappings);

    joinedSubclass.createPrimaryKey();

    // properties
    createClassProperties(sub, joinedSubclass, mappings, sessionFactoryBeanName);
}