Example usage for org.hibernate.mapping RootClass setMutable

List of usage examples for org.hibernate.mapping RootClass setMutable

Introduction

In this page you can find the example usage for org.hibernate.mapping RootClass setMutable.

Prototype

public void setMutable(boolean mutable) 

Source Link

Usage

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

License:Apache License

protected void bindRootPersistentClassCommonValues(GrailsDomainClass domainClass, RootClass root,
        Mappings mappings, String sessionFactoryBeanName) {

    // get the schema and catalog names from the configuration
    Mapping m = getMapping(domainClass.getClazz());
    String schema = mappings.getSchemaName();
    String catalog = mappings.getCatalogName();

    if (m != null) {
        configureDerivedProperties(domainClass, m);
        CacheConfig cc = m.getCache();/*from   w  w  w .j  a v a 2 s  . co  m*/
        if (cc != null && cc.getEnabled()) {
            root.setCacheConcurrencyStrategy(cc.getUsage());
            if ("read-only".equals(cc.getUsage())) {
                root.setMutable(false);
            }
            root.setLazyPropertiesCacheable(!"non-lazy".equals(cc.getInclude()));
        }

        Integer bs = m.getBatchSize();
        if (bs != null) {
            root.setBatchSize(bs);
        }

        if (m.getDynamicUpdate()) {
            root.setDynamicUpdate(true);
        }
        if (m.getDynamicInsert()) {
            root.setDynamicInsert(true);
        }
    }

    final boolean hasTableDefinition = m != null && m.getTable() != null;
    if (hasTableDefinition && m.getTable().getSchema() != null) {
        schema = m.getTable().getSchema();
    }
    if (hasTableDefinition && m.getTable().getCatalog() != null) {
        catalog = m.getTable().getCatalog();
    }

    final boolean isAbstract = m != null && !m.getTablePerHierarchy() && m.isTablePerConcreteClass()
            && root.isAbstract();
    // create the table
    Table table = mappings.addTable(schema, catalog, getTableName(domainClass, sessionFactoryBeanName), null,
            isAbstract);
    root.setTable(table);

    if (LOG.isDebugEnabled()) {
        LOG.debug("[GrailsDomainBinder] Mapping Grails domain class: " + domainClass.getFullName() + " -> "
                + root.getTable().getName());
    }

    bindIdentity(domainClass, root, mappings, m, sessionFactoryBeanName);

    if (m == null) {
        bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
    } else {
        if (m.getVersioned()) {
            bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
        }
    }

    root.createPrimaryKey();

    createClassProperties(domainClass, root, mappings, sessionFactoryBeanName);
}

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

License:Apache License

private static void bindRootPersistentClassCommonValues(GrailsDomainClass domainClass, RootClass root,
        Mappings mappings, String sessionFactoryBeanName) {

    // get the schema and catalog names from the configuration
    Mapping m = getMapping(domainClass.getClazz());
    String schema = mappings.getSchemaName();
    String catalog = mappings.getCatalogName();

    if (m != null) {
        configureDerivedProperties(domainClass, m);
        CacheConfig cc = m.getCache();/*from   ww  w . j  av a  2s. c  o m*/
        if (cc != null && cc.getEnabled()) {
            root.setCacheConcurrencyStrategy(cc.getUsage());
            if ("read-only".equals(cc.getUsage())) {
                root.setMutable(false);
            }
            root.setLazyPropertiesCacheable(!"non-lazy".equals(cc.getInclude()));
        }

        Integer bs = m.getBatchSize();
        if (bs != null) {
            root.setBatchSize(bs);
        }

        if (m.getDynamicUpdate()) {
            root.setDynamicUpdate(true);
        }
        if (m.getDynamicInsert()) {
            root.setDynamicInsert(true);
        }
    }

    final boolean hasTableDefinition = m != null && m.getTable() != null;
    if (hasTableDefinition && m.getTable().getSchema() != null) {
        schema = m.getTable().getSchema();
    }
    if (hasTableDefinition && m.getTable().getCatalog() != null) {
        catalog = m.getTable().getCatalog();
    }

    // create the table
    Table table = mappings.addTable(schema, catalog, getTableName(domainClass, sessionFactoryBeanName), null,
            false);
    root.setTable(table);

    if (LOG.isDebugEnabled()) {
        LOG.debug("[GrailsDomainBinder] Mapping Grails domain class: " + domainClass.getFullName() + " -> "
                + root.getTable().getName());
    }

    bindIdentity(domainClass, root, mappings, m, sessionFactoryBeanName);

    if (m != null) {
        if (m.getVersioned()) {
            bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
        }
    } else {
        bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
    }

    root.createPrimaryKey();

    createClassProperties(domainClass, root, mappings, sessionFactoryBeanName);
}

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

License:Apache License

protected void bindRootPersistentClassCommonValues(HibernatePersistentEntity domainClass, RootClass root,
        Mappings mappings, String sessionFactoryBeanName) {

    // get the schema and catalog names from the configuration
    Mapping m = getMapping(domainClass.getJavaClass());
    String schema = mappings.getSchemaName();
    String catalog = mappings.getCatalogName();

    if (m != null) {
        configureDerivedProperties(domainClass, m);
        CacheConfig cc = m.getCache();//from ww  w  .j  a  v a  2 s . com
        if (cc != null && cc.getEnabled()) {
            root.setCacheConcurrencyStrategy(cc.getUsage());
            if ("read-only".equals(cc.getUsage())) {
                root.setMutable(false);
            }
            root.setLazyPropertiesCacheable(!"non-lazy".equals(cc.getInclude()));
        }

        Integer bs = m.getBatchSize();
        if (bs != null) {
            root.setBatchSize(bs);
        }

        if (m.getDynamicUpdate()) {
            root.setDynamicUpdate(true);
        }
        if (m.getDynamicInsert()) {
            root.setDynamicInsert(true);
        }
    }

    final boolean hasTableDefinition = m != null && m.getTable() != null;
    if (hasTableDefinition && m.getTable().getSchema() != null) {
        schema = m.getTable().getSchema();
    }
    if (hasTableDefinition && m.getTable().getCatalog() != null) {
        catalog = m.getTable().getCatalog();
    }

    final boolean isAbstract = m != null && !m.getTablePerHierarchy() && m.isTablePerConcreteClass()
            && root.isAbstract();
    // create the table
    Table table = mappings.addTable(schema, catalog, getTableName(domainClass, sessionFactoryBeanName), null,
            isAbstract);
    root.setTable(table);

    if (LOG.isDebugEnabled()) {
        LOG.debug("[GrailsDomainBinder] Mapping Grails domain class: " + domainClass.getName() + " -> "
                + root.getTable().getName());
    }

    bindIdentity(domainClass, root, mappings, m, sessionFactoryBeanName);

    if (m == null) {
        bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
    } else {
        if (m.getVersioned()) {
            bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
        }
    }

    root.createPrimaryKey();

    createClassProperties(domainClass, root, mappings, sessionFactoryBeanName);
}

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

License:Apache License

protected void bindRootPersistentClassCommonValues(HibernatePersistentEntity domainClass, RootClass root,
        InFlightMetadataCollector mappings, String sessionFactoryBeanName) {

    // get the schema and catalog names from the configuration
    Mapping m = getMapping(domainClass.getJavaClass());

    String schema = getSchemaName(mappings);
    String catalog = getCatalogName(mappings);

    if (m != null) {
        configureDerivedProperties(domainClass, m);
        CacheConfig cc = m.getCache();// w  w w. ja  va  2 s  .c o m
        if (cc != null && cc.getEnabled()) {
            root.setCacheConcurrencyStrategy(cc.getUsage());
            if ("read-only".equals(cc.getUsage())) {
                root.setMutable(false);
            }
            root.setLazyPropertiesCacheable(!"non-lazy".equals(cc.getInclude()));
        }

        Integer bs = m.getBatchSize();
        if (bs != null) {
            root.setBatchSize(bs);
        }

        if (m.getDynamicUpdate()) {
            root.setDynamicUpdate(true);
        }
        if (m.getDynamicInsert()) {
            root.setDynamicInsert(true);
        }
    }

    final boolean hasTableDefinition = m != null && m.getTable() != null;
    if (hasTableDefinition && m.getTable().getSchema() != null) {
        schema = m.getTable().getSchema();
    }
    if (hasTableDefinition && m.getTable().getCatalog() != null) {
        catalog = m.getTable().getCatalog();
    }

    final boolean isAbstract = m != null && !m.getTablePerHierarchy() && m.isTablePerConcreteClass()
            && root.isAbstract();
    // create the table
    Table table = mappings.addTable(schema, catalog, getTableName(domainClass, sessionFactoryBeanName), null,
            isAbstract);
    root.setTable(table);

    if (LOG.isDebugEnabled()) {
        LOG.debug("[GrailsDomainBinder] Mapping Grails domain class: " + domainClass.getName() + " -> "
                + root.getTable().getName());
    }

    bindIdentity(domainClass, root, mappings, m, sessionFactoryBeanName);

    if (m == null) {
        bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
    } else {
        if (m.getVersioned()) {
            bindVersion(domainClass.getVersion(), root, mappings, sessionFactoryBeanName);
        }
    }

    root.createPrimaryKey();

    createClassProperties(domainClass, root, mappings, sessionFactoryBeanName);
}