List of usage examples for org.hibernate.mapping RootClass isAbstract
public Boolean isAbstract()
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 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(); } 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.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();// w w w . j a v a2 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); }
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();//from w w w . ja va2s .c om 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.jboss.tools.hibernate.ui.diagram.editors.model.OrmShape.java
License:Open Source License
@Override public Object getPropertyValue(Object propertyId) { Object res = null;/*from w w w . ja v a 2 s. c o m*/ RootClass rootClass = null; Table table = null; Object ormElement = getOrmElement(); if (ormElement instanceof RootClass) { rootClass = (RootClass) ormElement; } else if (ormElement instanceof Subclass) { //rootClass = ((Subclass)ormElement).getRootClass(); } else if (ormElement instanceof Table) { table = (Table) getOrmElement(); } if (rootClass != null) { if (ENTITY_isAbstract.equals(propertyId)) { if (rootClass.isAbstract() != null) { res = rootClass.isAbstract().toString(); } } else if (ENTITY_isCustomDeleteCallable.equals(propertyId)) { res = Boolean.valueOf(rootClass.isCustomDeleteCallable()).toString(); } else if (ENTITY_isCustomInsertCallable.equals(propertyId)) { res = Boolean.valueOf(rootClass.isCustomInsertCallable()).toString(); } else if (ENTITY_isCustomUpdateCallable.equals(propertyId)) { res = Boolean.valueOf(rootClass.isCustomUpdateCallable()).toString(); } else if (ENTITY_isDiscriminatorInsertable.equals(propertyId)) { res = Boolean.valueOf(rootClass.isDiscriminatorInsertable()).toString(); } else if (ENTITY_isDiscriminatorValueNotNull.equals(propertyId)) { res = Boolean.valueOf(rootClass.isDiscriminatorValueNotNull()).toString(); } else if (ENTITY_isDiscriminatorValueNull.equals(propertyId)) { res = Boolean.valueOf(rootClass.isDiscriminatorValueNull()).toString(); } else if (ENTITY_isExplicitPolymorphism.equals(propertyId)) { res = Boolean.valueOf(rootClass.isExplicitPolymorphism()).toString(); } else if (ENTITY_isForceDiscriminator.equals(propertyId)) { res = Boolean.valueOf(rootClass.isForceDiscriminator()).toString(); } else if (ENTITY_isInherited.equals(propertyId)) { res = Boolean.valueOf(rootClass.isInherited()).toString(); } else if (ENTITY_isJoinedSubclass.equals(propertyId)) { res = Boolean.valueOf(rootClass.isJoinedSubclass()).toString(); } else if (ENTITY_isLazy.equals(propertyId)) { res = Boolean.valueOf(rootClass.isLazy()).toString(); } else if (ENTITY_isLazyPropertiesCacheable.equals(propertyId)) { res = Boolean.valueOf(rootClass.isLazyPropertiesCacheable()).toString(); } else if (ENTITY_isMutable.equals(propertyId)) { res = Boolean.valueOf(rootClass.isMutable()).toString(); } else if (ENTITY_isPolymorphic.equals(propertyId)) { res = Boolean.valueOf(rootClass.isPolymorphic()).toString(); } else if (ENTITY_isVersioned.equals(propertyId)) { res = Boolean.valueOf(rootClass.isVersioned()).toString(); } else if (ENTITY_batchSize.equals(propertyId)) { res = Integer.valueOf(rootClass.getBatchSize()).toString(); } else if (ENTITY_cacheConcurrencyStrategy.equals(propertyId)) { res = rootClass.getCacheConcurrencyStrategy(); } else if (ENTITY_className.equals(propertyId)) { res = rootClass.getClassName(); } else if (ENTITY_customSQLDelete.equals(propertyId)) { res = rootClass.getCustomSQLDelete(); } else if (ENTITY_customSQLInsert.equals(propertyId)) { res = rootClass.getCustomSQLInsert(); } else if (ENTITY_customSQLUpdate.equals(propertyId)) { res = rootClass.getCustomSQLUpdate(); } else if (ENTITY_discriminatorValue.equals(propertyId)) { res = rootClass.getDiscriminatorValue(); } else if (ENTITY_entityName.equals(propertyId)) { res = rootClass.getEntityName(); } else if (ENTITY_loaderName.equals(propertyId)) { res = rootClass.getLoaderName(); } else if (ENTITY_nodeName.equals(propertyId)) { res = rootClass.getNodeName(); } else if (ENTITY_optimisticLockMode.equals(propertyId)) { res = Integer.valueOf(rootClass.getOptimisticLockMode()).toString(); } else if (ENTITY_table.equals(propertyId)) { if (rootClass.getTable() != null) { res = rootClass.getTable().getName(); } } else if (ENTITY_temporaryIdTableDDL.equals(propertyId)) { res = rootClass.getTemporaryIdTableDDL(); } else if (ENTITY_temporaryIdTableName.equals(propertyId)) { res = rootClass.getTemporaryIdTableName(); } else if (ENTITY_where.equals(propertyId)) { res = rootClass.getWhere(); } } if (table != null) { if (TABLE_catalog.equals(propertyId)) { res = table.getCatalog(); } else if (TABLE_comment.equals(propertyId)) { res = table.getComment(); } else if (TABLE_name.equals(propertyId)) { res = table.getName(); } else if (TABLE_primaryKey.equals(propertyId)) { if (table.getPrimaryKey() != null) { res = table.getPrimaryKey().getName(); } } else if (TABLE_rowId.equals(propertyId)) { res = table.getRowId(); } else if (TABLE_schema.equals(propertyId)) { res = table.getSchema(); } else if (TABLE_subselect.equals(propertyId)) { res = table.getSubselect(); } else if (TABLE_hasDenormalizedTables.equals(propertyId)) { res = Boolean.valueOf(table.hasDenormalizedTables()).toString(); } else if (TABLE_isAbstract.equals(propertyId)) { res = Boolean.valueOf(table.isAbstract()).toString(); } else if (TABLE_isAbstractUnionTable.equals(propertyId)) { res = Boolean.valueOf(table.isAbstractUnionTable()).toString(); } else if (TABLE_isPhysicalTable.equals(propertyId)) { res = Boolean.valueOf(table.isPhysicalTable()).toString(); } } if (res == null) { res = super.getPropertyValue(propertyId); } return toEmptyStr(res); }