List of usage examples for org.hibernate.mapping PersistentClass addTuplizer
public void addTuplizer(EntityMode entityMode, String implClassName)
From source file:org.eclipse.emf.teneo.hibernate.HbDataStore.java
License:Open Source License
/** Sets the tuplizer */ protected void setTuplizer() { for (Iterator<?> pcs = getClassMappings(); pcs.hasNext();) { final PersistentClass pc = (PersistentClass) pcs.next(); if (pc.getMetaAttribute(HbMapperConstants.FEATUREMAP_META) != null) { // featuremap // entry pc.addTuplizer(EntityMode.MAP, getHbContext().getFeatureMapEntryTuplizer(getHibernateConfiguration()).getName()); } else if (pc.getMetaAttribute(HbMapperConstants.ECLASS_NAME_META) != null) { // only the pc's with this meta should get a tuplizer pc.addTuplizer(EntityMode.MAP, getHbContext().getEMFTuplizerClass(getHibernateConfiguration()).getName()); pc.addTuplizer(EntityMode.POJO, getHbContext().getEMFTuplizerClass(getHibernateConfiguration()).getName()); } else if (pc.getMetaAttribute(HbMapperConstants.ECLASS_NAME_META) == null) { // don't change these pc's any further, these are not eclasses continue; }/*from w w w. j av a 2 s. c om*/ // also set the tuplizer for the components, and register for the // component // Build a list of all properties. java.util.List<Property> properties = new ArrayList<Property>(); final Property identifierProperty = pc.getIdentifierProperty(); if (identifierProperty != null) { properties.add(identifierProperty); } for (Iterator<?> it = pc.getPropertyIterator(); it.hasNext();) { properties.add((Property) it.next()); } // Now set component tuplizers where necessary. for (Object name2 : properties) { Property prop = (Property) name2; if (prop.getName().compareTo("_identifierMapper") == 0) { continue; // ignore this one } final Value value = prop.getValue(); if (value instanceof Component) { setComponentTuplizer((Component) value, getHibernateConfiguration()); } else if (value instanceof Collection && ((Collection) value).getElement() instanceof Component) { setComponentTuplizer((Component) ((Collection) value).getElement(), getHibernateConfiguration()); } } } }
From source file:org.grails.orm.hibernate.cfg.GrailsDomainBinder.java
License:Apache License
/** * Binds the specified persistant class to the runtime model based on the * properties defined in the domain class * * @param domainClass The Grails domain class * @param persistentClass The persistant class * @param mappings Existing mappings *///from www .j a va 2s . c om protected void bindClass(PersistentEntity domainClass, PersistentClass persistentClass, InFlightMetadataCollector mappings) { // set lazy loading for now persistentClass.setLazy(true); final String entityName = domainClass.getName(); persistentClass.setEntityName(entityName); persistentClass.setJpaEntityName(unqualify(entityName)); persistentClass.setProxyInterfaceName(entityName); persistentClass.setClassName(entityName); persistentClass.addTuplizer(EntityMode.POJO, GroovyAwarePojoEntityTuplizer.class.getName()); // set dynamic insert to false persistentClass.setDynamicInsert(false); // set dynamic update to false persistentClass.setDynamicUpdate(false); // set select before update to false persistentClass.setSelectBeforeUpdate(false); // add import to mappings String en = persistentClass.getEntityName(); if (mappings.getMetadataBuildingOptions().getMappingDefaults().isAutoImportEnabled() && en.indexOf('.') > 0) { String unqualified = unqualify(en); mappings.addImport(unqualified, en); } }