/** * Binds a Grails domain class to the Hibernate runtime meta model * * @param entity The domain class to bind * @param mappings The existing mappings * @param sessionFactoryBeanName the session factory bean name * @throws MappingException Thrown if the domain class uses inheritance which is not supported */ public void bindClass(PersistentEntity entity, Mappings mappings, String sessionFactoryBeanName) throws MappingException { //if (domainClass.getClazz().getSuperclass() == Object.class) { if (entity.isRoot()) { bindRoot((HibernatePersistentEntity) entity, mappings, sessionFactoryBeanName); } }
/** * Returns true if the given entity is in an inheritance hierarchy * * @param entity The entity * @return True if it is */ public boolean isInInheritanceHierarchy(PersistentEntity entity) { if (entity != null) { if (!entity.isRoot()) return true; PersistentEntity rootEntity = entity.getRootEntity(); final Map<String, PersistentEntity> children = persistentEntitiesByDiscriminator.get(rootEntity); if (children != null && !children.isEmpty()) { return true; } } return false; }
if (!entity.isRoot()) { PersistentEntity parent = entity.getParentEntity();
@Override public boolean isInherited() { if (inherited == null) { if (owner.isRoot()) { inherited = false; } else { PersistentEntity parentEntity = owner.getParentEntity(); boolean foundInParent = false; while (parentEntity != null) { final PersistentProperty p = parentEntity.getPropertyByName(name); if (p != null) { foundInParent = true; break; } parentEntity = parentEntity.getParentEntity(); } inherited = foundInParent; } } return inherited; }
protected boolean isComponentPropertyNullable(PersistentProperty componentProperty) { if (componentProperty == null) return false; final PersistentEntity domainClass = componentProperty.getOwner(); final Mapping mapping = getMapping(domainClass.getJavaClass()); return !domainClass.isRoot() && (mapping == null || mapping.isTablePerHierarchy()) || componentProperty.isNullable(); }
Column column = new Column(); if (owner.isRoot()) { column.setNullable(property.isNullable()); } else {
if (!owner.isRoot()) { Mapping mapping = getMapping(owner); if (mapping == null || mapping.getTablePerHierarchy()) {
boolean tablePerSubclass = m != null && !m.getTablePerHierarchy(); if (referenced != null && !referenced.isRoot() && !tablePerSubclass) { Mapping rootMapping = getRootMapping(referenced); String discriminatorColumnName = RootClass.DEFAULT_DISCRIMINATOR_COLUMN_NAME;