List of usage examples for org.hibernate.mapping RootClass getEntityName
public String getEntityName()
From source file:com.manydesigns.portofino.persistence.hibernate.HibernateConfig.java
License:Open Source License
private Mappings classMapping(Database database, Mappings mappings) { for (Schema schema : database.getSchemas()) { for (com.manydesigns.portofino.model.database.Table aTable : schema.getTables()) { logger.debug("Class - {}", aTable.getQualifiedName()); com.manydesigns.portofino.model.database.PrimaryKey primaryKey = aTable.getPrimaryKey(); if (primaryKey == null) { logger.debug("Skipping table without primary key: {}", aTable.getQualifiedName()); continue; }// ww w .ja v a 2s .co m if (!primaryKey.isValid()) { logger.debug("Skipping table with invalid primary key: {}", aTable.getQualifiedName()); continue; } RootClass clazz = createTableMapping(mappings, aTable); if (clazz != null) { mappings.addClass(clazz); mappings.addImport(clazz.getEntityName(), clazz.getEntityName()); } } } return mappings; }
From source file:com.manydesigns.portofino.persistence.hibernate.HibernateConfig.java
License:Open Source License
protected void setPKColumnGenerator(Mappings mappings, RootClass clazz, Table tab, com.manydesigns.portofino.model.database.Column column, SimpleValue id, Generator generator) { if (column.isAutoincrement()) { manageIdentityGenerator(mappings, tab, id); } else if (generator != null) { if (generator instanceof SequenceGenerator) { manageSequenceGenerator(mappings, tab, id, (SequenceGenerator) generator); } else if (generator instanceof com.manydesigns.portofino.model.database.TableGenerator) { manageTableGenerator(mappings, tab, id, (com.manydesigns.portofino.model.database.TableGenerator) generator); } else if (generator instanceof com.manydesigns.portofino.model.database.IncrementGenerator) { manageIncrementGenerator(mappings, tab, id, clazz.getEntityName()); }/*from ww w . jav a 2s . c o m*/ } }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void bindCompositeId(GrailsDomainClass domainClass, RootClass root, CompositeIdentity compositeIdentity, Mappings mappings, String sessionFactoryBeanName) { Component id = new Component(mappings, root); id.setNullValue("undefined"); root.setIdentifier(id);/*from w w w .ja va 2s . c om*/ root.setEmbeddedIdentifier(true); id.setComponentClassName(domainClass.getFullName()); id.setKey(true); id.setEmbedded(true); String path = qualify(root.getEntityName(), "id"); id.setRoleName(path); String[] props = compositeIdentity.getPropertyNames(); for (String propName : props) { GrailsDomainClassProperty property = domainClass.getPropertyByName(propName); if (property == null) { throw new MappingException( "Property [" + propName + "] referenced in composite-id mapping of class [" + domainClass.getFullName() + "] is not a valid property!"); } bindComponentProperty(id, null, property, root, "", root.getTable(), mappings, sessionFactoryBeanName); } }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
private static void bindCompositeId(GrailsDomainClass domainClass, RootClass root, CompositeIdentity compositeIdentity, Mappings mappings, String sessionFactoryBeanName) { Component id = new Component(mappings, root); id.setNullValue("undefined"); root.setIdentifier(id);/*from ww w .j a v a 2s .c o m*/ root.setEmbeddedIdentifier(true); id.setComponentClassName(domainClass.getFullName()); id.setKey(true); id.setEmbedded(true); String path = StringHelper.qualify(root.getEntityName(), "id"); id.setRoleName(path); String[] props = compositeIdentity.getPropertyNames(); for (String propName : props) { GrailsDomainClassProperty property = domainClass.getPropertyByName(propName); if (property == null) { throw new MappingException( "Property [" + propName + "] referenced in composite-id mapping of class [" + domainClass.getFullName() + "] is not a valid property!"); } bindComponentProperty(id, null, property, root, "", root.getTable(), mappings, sessionFactoryBeanName); } }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
protected void bindCompositeId(PersistentEntity domainClass, RootClass root, CompositeIdentity compositeIdentity, Mappings mappings, String sessionFactoryBeanName) { HibernatePersistentEntity hibernatePersistentEntity = (HibernatePersistentEntity) domainClass; Component id = new Component(mappings, root); id.setNullValue("undefined"); root.setIdentifier(id);//ww w .j av a 2 s . c o m root.setEmbeddedIdentifier(true); id.setComponentClassName(domainClass.getName()); id.setKey(true); id.setEmbedded(true); String path = qualify(root.getEntityName(), "id"); id.setRoleName(path); final PersistentProperty[] composite = hibernatePersistentEntity.getCompositeIdentity(); for (PersistentProperty property : composite) { if (property == null) { throw new MappingException("Property referenced in composite-id mapping of class [" + domainClass.getName() + "] is not a valid property!"); } bindComponentProperty(id, null, property, root, "", root.getTable(), mappings, sessionFactoryBeanName); } }
From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
protected void bindCompositeId(PersistentEntity domainClass, RootClass root, CompositeIdentity compositeIdentity, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { HibernatePersistentEntity hibernatePersistentEntity = (HibernatePersistentEntity) domainClass; Component id = new Component(mappings, root); id.setNullValue("undefined"); root.setIdentifier(id);//from w w w. j av a 2 s . co m root.setEmbeddedIdentifier(true); id.setComponentClassName(domainClass.getName()); id.setKey(true); id.setEmbedded(true); String path = qualify(root.getEntityName(), "id"); id.setRoleName(path); final PersistentProperty[] composite = hibernatePersistentEntity.getCompositeIdentity(); for (PersistentProperty property : composite) { if (property == null) { throw new MappingException("Property referenced in composite-id mapping of class [" + domainClass.getName() + "] is not a valid property!"); } bindComponentProperty(id, null, property, root, "", root.getTable(), 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 .java2 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); }