List of usage examples for org.hibernate.mapping RootClass getEntityPersisterClass
@Override
public Class getEntityPersisterClass()
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
/** * Binds a root class (one with no super classes) to the runtime meta model * based on the supplied Grails domain class * * @param domainClass The Grails domain class * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name */// w w w .j a v a 2 s. c om public void bindRoot(GrailsDomainClass domainClass, Mappings mappings, String sessionFactoryBeanName) { if (mappings.getClass(domainClass.getFullName()) != null) { LOG.info("[GrailsDomainBinder] Class [" + domainClass.getFullName() + "] is already mapped, skipping.. "); return; } RootClass root = new RootClass(); root.setAbstract(Modifier.isAbstract(domainClass.getClazz().getModifiers())); if (!domainClass.hasSubClasses()) { root.setPolymorphic(false); } bindClass(domainClass, root, mappings); Mapping m = getMapping(domainClass); bindRootPersistentClassCommonValues(domainClass, root, mappings, sessionFactoryBeanName); if (!domainClass.getSubClasses().isEmpty()) { boolean tablePerSubclass = m != null && !m.getTablePerHierarchy(); if (!tablePerSubclass) { // if the root class has children create a discriminator property bindDiscriminatorProperty(root.getTable(), root, mappings); } // bind the sub classes bindSubClasses(domainClass, root, mappings, sessionFactoryBeanName); } if (root.getEntityPersisterClass() == null) { root.setEntityPersisterClass(getGroovyAwareSingleTableEntityPersisterClass()); } mappings.addClass(root); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
/** * Binds a root class (one with no super classes) to the runtime meta model * based on the supplied Grails domain class * * @param domainClass The Grails domain class * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name *//*from w w w . j a v a 2 s. c o m*/ public static void bindRoot(GrailsDomainClass domainClass, Mappings mappings, String sessionFactoryBeanName) { if (mappings.getClass(domainClass.getFullName()) != null) { LOG.info("[GrailsDomainBinder] Class [" + domainClass.getFullName() + "] is already mapped, skipping.. "); return; } RootClass root = new RootClass(); root.setAbstract(Modifier.isAbstract(domainClass.getClazz().getModifiers())); if (!domainClass.hasSubClasses()) { root.setPolymorphic(false); } bindClass(domainClass, root, mappings); Mapping m = getMapping(domainClass); bindRootPersistentClassCommonValues(domainClass, root, mappings, sessionFactoryBeanName); if (!domainClass.getSubClasses().isEmpty()) { boolean tablePerSubclass = m != null && !m.getTablePerHierarchy(); if (!tablePerSubclass) { // if the root class has children create a discriminator property bindDiscriminatorProperty(root.getTable(), root, mappings); } // bind the sub classes bindSubClasses(domainClass, root, mappings, sessionFactoryBeanName); } if (root.getEntityPersisterClass() == null) { root.setEntityPersisterClass(GroovyAwareSingleTableEntityPersister.class); } mappings.addClass(root); }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
/** * Binds a root class (one with no super classes) to the runtime meta model * based on the supplied Grails domain class * * @param entity The Grails domain class * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name *//*from w w w .ja v a2s. c om*/ public void bindRoot(HibernatePersistentEntity entity, Mappings mappings, String sessionFactoryBeanName) { if (mappings.getClass(entity.getName()) != null) { LOG.info("[GrailsDomainBinder] Class [" + entity.getName() + "] is already mapped, skipping.. "); return; } RootClass root = new RootClass(); root.setAbstract(entity.isAbstract()); final MappingContext mappingContext = entity.getMappingContext(); final java.util.Collection<PersistentEntity> children = mappingContext.getDirectChildEntities(entity); if (children.isEmpty()) { root.setPolymorphic(false); } bindClass(entity, root, mappings); Mapping m = getMapping(entity); bindRootPersistentClassCommonValues(entity, root, mappings, sessionFactoryBeanName); if (!children.isEmpty()) { boolean tablePerSubclass = m != null && !m.getTablePerHierarchy(); if (!tablePerSubclass) { // if the root class has children create a discriminator property bindDiscriminatorProperty(root.getTable(), root, mappings); } // bind the sub classes bindSubClasses(entity, root, mappings, sessionFactoryBeanName); } if (root.getEntityPersisterClass() == null) { root.setEntityPersisterClass(getGroovyAwareSingleTableEntityPersisterClass()); } mappings.addClass(root); }