List of usage examples for org.hibernate.mapping Component setParentProperty
public void setParentProperty(String parentProperty)
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
/** * Binds a Hibernate component type using the given GrailsDomainClassProperty instance * * @param component The component to bind * @param property The property/*from ww w . j av a 2 s . c o m*/ * @param isNullable Whether it is nullable or not * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name */ protected void bindComponent(Component component, GrailsDomainClassProperty property, boolean isNullable, Mappings mappings, String sessionFactoryBeanName) { component.setEmbedded(true); Class<?> type = property.getType(); String role = qualify(type.getName(), property.getName()); component.setRoleName(role); component.setComponentClassName(type.getName()); GrailsDomainClass domainClass = property.getReferencedDomainClass() != null ? property.getReferencedDomainClass() : property.getComponent(); evaluateMapping(domainClass); GrailsDomainClassProperty[] properties = domainClass.getPersistentProperties(); Table table = component.getOwner().getTable(); PersistentClass persistentClass = component.getOwner(); String path = property.getName(); Class<?> propertyType = property.getDomainClass().getClazz(); for (GrailsDomainClassProperty currentGrailsProp : properties) { if (currentGrailsProp.isIdentity()) continue; if (currentGrailsProp.getName().equals(GrailsDomainClassProperty.VERSION)) continue; if (currentGrailsProp.getType().equals(propertyType)) { component.setParentProperty(currentGrailsProp.getName()); continue; } bindComponentProperty(component, property, currentGrailsProp, persistentClass, path, table, mappings, sessionFactoryBeanName); } }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
/** * Binds a Hibernate component type using the given GrailsDomainClassProperty instance * * @param component The component to bind * @param property The property//from w w w.j a va 2 s .co m * @param isNullable Whether it is nullable or not * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name */ private static void bindComponent(Component component, GrailsDomainClassProperty property, @SuppressWarnings("unused") boolean isNullable, Mappings mappings, String sessionFactoryBeanName) { component.setEmbedded(true); Class<?> type = property.getType(); String role = StringHelper.qualify(type.getName(), property.getName()); component.setRoleName(role); component.setComponentClassName(type.getName()); GrailsDomainClass domainClass = property.getReferencedDomainClass() != null ? property.getReferencedDomainClass() : property.getComponent(); evaluateMapping(domainClass); GrailsDomainClassProperty[] properties = domainClass.getPersistentProperties(); Table table = component.getOwner().getTable(); PersistentClass persistentClass = component.getOwner(); String path = property.getName(); Class<?> propertyType = property.getDomainClass().getClazz(); for (GrailsDomainClassProperty currentGrailsProp : properties) { if (currentGrailsProp.isIdentity()) continue; if (currentGrailsProp.getName().equals(GrailsDomainClassProperty.VERSION)) continue; if (currentGrailsProp.getType().equals(propertyType)) { component.setParentProperty(currentGrailsProp.getName()); continue; } bindComponentProperty(component, property, currentGrailsProp, persistentClass, path, table, mappings, sessionFactoryBeanName); } }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.java
License:Apache License
/** * Binds a Hibernate component type using the given GrailsDomainClassProperty instance * * @param component The component to bind * @param property The property// w w w. ja v a2 s .c om * @param isNullable Whether it is nullable or not * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name */ protected void bindComponent(Component component, Embedded property, boolean isNullable, Mappings mappings, String sessionFactoryBeanName) { component.setEmbedded(true); Class<?> type = property.getType(); String role = qualify(type.getName(), property.getName()); component.setRoleName(role); component.setComponentClassName(type.getName()); PersistentEntity domainClass = property.getAssociatedEntity(); evaluateMapping(domainClass, defaultMapping); final List<PersistentProperty> properties = domainClass.getPersistentProperties(); Table table = component.getOwner().getTable(); PersistentClass persistentClass = component.getOwner(); String path = property.getName(); Class<?> propertyType = property.getOwner().getJavaClass(); for (PersistentProperty currentGrailsProp : properties) { if (currentGrailsProp.equals(domainClass.getIdentity())) continue; if (currentGrailsProp.getName().equals(GormProperties.VERSION)) continue; if (currentGrailsProp.getType().equals(propertyType)) { component.setParentProperty(currentGrailsProp.getName()); continue; } bindComponentProperty(component, property, currentGrailsProp, persistentClass, path, table, mappings, sessionFactoryBeanName); } }
From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
/** * Binds a Hibernate component type using the given GrailsDomainClassProperty instance * * @param component The component to bind * @param property The property/*from w ww . ja va 2s . com*/ * @param isNullable Whether it is nullable or not * @param mappings The Hibernate Mappings object * @param sessionFactoryBeanName the session factory bean name */ protected void bindComponent(Component component, Embedded property, boolean isNullable, InFlightMetadataCollector mappings, String sessionFactoryBeanName) { component.setEmbedded(true); Class<?> type = property.getType(); String role = qualify(type.getName(), property.getName()); component.setRoleName(role); component.setComponentClassName(type.getName()); PersistentEntity domainClass = property.getAssociatedEntity(); evaluateMapping(domainClass, defaultMapping); final List<PersistentProperty> properties = domainClass.getPersistentProperties(); Table table = component.getOwner().getTable(); PersistentClass persistentClass = component.getOwner(); String path = property.getName(); Class<?> propertyType = property.getOwner().getJavaClass(); for (PersistentProperty currentGrailsProp : properties) { if (currentGrailsProp.equals(domainClass.getIdentity())) continue; if (currentGrailsProp.getName().equals(GormProperties.VERSION)) continue; if (currentGrailsProp.getType().equals(propertyType)) { component.setParentProperty(currentGrailsProp.getName()); continue; } bindComponentProperty(component, property, currentGrailsProp, persistentClass, path, table, mappings, sessionFactoryBeanName); } }