List of usage examples for org.hibernate.mapping PersistentClass setClassName
public void setClassName(String className)
From source file:org.beangle.orm.hibernate.internal.PersistentClassMerger.java
License:Open Source License
public static void merge(PersistentClass sub, PersistentClass parent) { if (!mergeSupport) throw new RuntimeException("Merge not supported!"); String className = sub.getClassName(); // 1. convert old to mapped superclass MappedSuperclass msc = new MappedSuperclass(parent.getSuperMappedSuperclass(), null); final Class<?> parentClass = parent.getMappedClass(); msc.setMappedClass(parentClass);// w w w . j a va 2s .c om // 2.clear old subclass property parent.setSuperMappedSuperclass(msc); parent.setClassName(className); parent.setProxyInterfaceName(className); if (parent instanceof RootClass) { if (!parentClass.getSuperclass().isAnnotationPresent(Entity.class)) { ((RootClass) parent).setDiscriminator(null); ((RootClass) parent).setPolymorphic(false); @SuppressWarnings("unchecked") Iterator<Column> iter = parent.getTable().getColumnIterator(); while (iter.hasNext()) { if (iter.next().getName().equalsIgnoreCase("dtype")) { iter.remove(); break; } } } } try { @SuppressWarnings("unchecked") List<Property> declareProperties = (List<Property>) declarePropertyField.get(parent); for (Property p : declareProperties) msc.addDeclaredProperty(p); ((List<?>) subPropertyField.get(parent)).clear(); ((List<?>) subclassField.get(parent)).clear(); } catch (Exception e) { } // 3. add property to old try { Iterator<?> pIter = sub.getPropertyIterator(); while (pIter.hasNext()) { Property p = (Property) pIter.next(); parent.addProperty(p); } } catch (Exception e) { } logger.info("{} replace {}.", sub.getClassName(), parent.getClassName()); }
From source file:org.codehaus.groovy.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.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 ww w .ja v a2s. c om*/ protected void bindClass(GrailsDomainClass domainClass, PersistentClass persistentClass, Mappings mappings) { // set lazy loading for now persistentClass.setLazy(true); persistentClass.setEntityName(domainClass.getFullName()); persistentClass.setJpaEntityName(unqualify(domainClass.getFullName())); persistentClass.setProxyInterfaceName(domainClass.getFullName()); persistentClass.setClassName(domainClass.getFullName()); // 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 if (mappings.isAutoImport() && persistentClass.getEntityName().indexOf('.') > 0) { mappings.addImport(persistentClass.getEntityName(), unqualify(persistentClass.getEntityName())); } }
From source file:org.codehaus.groovy.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 ww w . j av a 2 s .c o m private static void bindClass(GrailsDomainClass domainClass, PersistentClass persistentClass, Mappings mappings) { // set lazy loading for now persistentClass.setLazy(true); persistentClass.setEntityName(domainClass.getFullName()); persistentClass.setProxyInterfaceName(domainClass.getFullName()); persistentClass.setClassName(domainClass.getFullName()); // 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 if (mappings.isAutoImport() && persistentClass.getEntityName().indexOf('.') > 0) { mappings.addImport(persistentClass.getEntityName(), StringHelper.unqualify(persistentClass.getEntityName())); } }
From source file:org.grails.orm.hibernate.cfg.AbstractGrailsDomainBinder.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 w w w .j a v a 2s. com*/ protected void bindClass(PersistentEntity domainClass, PersistentClass persistentClass, Mappings 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); // 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 if (mappings.isAutoImport() && persistentClass.getEntityName().indexOf('.') > 0) { mappings.addImport(persistentClass.getEntityName(), unqualify(persistentClass.getEntityName())); } }
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 ww w. java 2 s . c o m*/ 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); } }