Example usage for org.hibernate.mapping PersistentClass setEntityName

List of usage examples for org.hibernate.mapping PersistentClass setEntityName

Introduction

In this page you can find the example usage for org.hibernate.mapping PersistentClass setEntityName.

Prototype

public void setEntityName(String entityName) 

Source Link

Usage

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

License:Apache License

/**
 * Binds the specified persistant class to the runtime model based on the
 * properties defined in the domain class
 *
 * @param domainClass     The Grails domain class
 * @param persistentClass The persistant class
 * @param mappings        Existing mappings
 *///from w ww. j av  a  2s  .  c o  m
protected void bindClass(GrailsDomainClass domainClass, PersistentClass persistentClass, Mappings mappings) {

    // set lazy loading for now
    persistentClass.setLazy(true);
    persistentClass.setEntityName(domainClass.getFullName());
    persistentClass.setJpaEntityName(unqualify(domainClass.getFullName()));
    persistentClass.setProxyInterfaceName(domainClass.getFullName());
    persistentClass.setClassName(domainClass.getFullName());

    // set dynamic insert to false
    persistentClass.setDynamicInsert(false);
    // set dynamic update to false
    persistentClass.setDynamicUpdate(false);
    // set select before update to false
    persistentClass.setSelectBeforeUpdate(false);

    // add import to mappings
    if (mappings.isAutoImport() && persistentClass.getEntityName().indexOf('.') > 0) {
        mappings.addImport(persistentClass.getEntityName(), unqualify(persistentClass.getEntityName()));
    }
}

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

License:Apache License

/**
 * Binds the specified persistant class to the runtime model based on the
 * properties defined in the domain class
 *
 * @param domainClass     The Grails domain class
 * @param persistentClass The persistant class
 * @param mappings        Existing mappings
 *//*from  w w w .  j  a va 2 s  .  c om*/
private static void bindClass(GrailsDomainClass domainClass, PersistentClass persistentClass,
        Mappings mappings) {

    // set lazy loading for now
    persistentClass.setLazy(true);
    persistentClass.setEntityName(domainClass.getFullName());
    persistentClass.setProxyInterfaceName(domainClass.getFullName());
    persistentClass.setClassName(domainClass.getFullName());

    // set dynamic insert to false
    persistentClass.setDynamicInsert(false);
    // set dynamic update to false
    persistentClass.setDynamicUpdate(false);
    // set select before update to false
    persistentClass.setSelectBeforeUpdate(false);

    // add import to mappings
    if (mappings.isAutoImport() && persistentClass.getEntityName().indexOf('.') > 0) {
        mappings.addImport(persistentClass.getEntityName(),
                StringHelper.unqualify(persistentClass.getEntityName()));
    }
}

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

License:Apache License

/**
 * Binds the specified persistant class to the runtime model based on the
 * properties defined in the domain class
 *
 * @param domainClass     The Grails domain class
 * @param persistentClass The persistant class
 * @param mappings        Existing mappings
 *///  w ww . ja  v a 2  s  .  c o m
protected void bindClass(PersistentEntity domainClass, PersistentClass persistentClass, Mappings mappings) {

    // set lazy loading for now
    persistentClass.setLazy(true);
    final String entityName = domainClass.getName();
    persistentClass.setEntityName(entityName);
    persistentClass.setJpaEntityName(unqualify(entityName));
    persistentClass.setProxyInterfaceName(entityName);
    persistentClass.setClassName(entityName);

    // set dynamic insert to false
    persistentClass.setDynamicInsert(false);
    // set dynamic update to false
    persistentClass.setDynamicUpdate(false);
    // set select before update to false
    persistentClass.setSelectBeforeUpdate(false);

    // add import to mappings
    if (mappings.isAutoImport() && persistentClass.getEntityName().indexOf('.') > 0) {
        mappings.addImport(persistentClass.getEntityName(), unqualify(persistentClass.getEntityName()));
    }
}

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

License:Apache License

/**
 * Binds the specified persistant class to the runtime model based on the
 * properties defined in the domain class
 *
 * @param domainClass     The Grails domain class
 * @param persistentClass The persistant class
 * @param mappings        Existing mappings
 *//*from   w  ww .  java 2  s.c  o  m*/
protected void bindClass(PersistentEntity domainClass, PersistentClass persistentClass,
        InFlightMetadataCollector mappings) {

    // set lazy loading for now
    persistentClass.setLazy(true);
    final String entityName = domainClass.getName();
    persistentClass.setEntityName(entityName);
    persistentClass.setJpaEntityName(unqualify(entityName));
    persistentClass.setProxyInterfaceName(entityName);
    persistentClass.setClassName(entityName);
    persistentClass.addTuplizer(EntityMode.POJO, GroovyAwarePojoEntityTuplizer.class.getName());

    // set dynamic insert to false
    persistentClass.setDynamicInsert(false);
    // set dynamic update to false
    persistentClass.setDynamicUpdate(false);
    // set select before update to false
    persistentClass.setSelectBeforeUpdate(false);

    // add import to mappings
    String en = persistentClass.getEntityName();
    if (mappings.getMetadataBuildingOptions().getMappingDefaults().isAutoImportEnabled()
            && en.indexOf('.') > 0) {
        String unqualified = unqualify(en);
        mappings.addImport(unqualified, en);
    }
}