List of usage examples for org.hibernate EntityMode POJO
EntityMode POJO
To view the source code for org.hibernate EntityMode POJO.
Click Source Link
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.jav 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.eclipse.emf.teneo.hibernate.HbDataStore.java
License:Open Source License
/** * Sets the emf component tuplizer (if it is an eclass) or the hibernate * component tuplizer//ww w . j ava2 s. co m */ protected void setComponentTuplizer(Component component, Configuration cfg) { // check if the eclass exists // todo: change recognizing a component to using metadata! EClass eClass = ERuntime.INSTANCE.getEClass(component.getComponentClass()); if (eClass == null) { eClass = getEntityNameStrategy().toEClass(component.getComponentClassName()); } if (eClass != null) { if (log.isDebugEnabled()) { log.debug("Found " + eClass.getName() + " as a component"); } } else { eClass = HbUtil.getEClassFromMeta(component); if (eClass == null) { return; } } // is a valid eclass component.addTuplizer(EntityMode.MAP, getHbContext().getEMFComponentTuplizerClass(cfg).getName()); component.addTuplizer(EntityMode.POJO, getHbContext().getEMFComponentTuplizerClass(cfg).getName()); HbHelper.INSTANCE.registerDataStoreByComponent(this, component); }
From source file:org.eclipse.emf.teneo.hibernate.mapping.eav.EAVObjectTuplizer.java
License:Open Source License
public EntityMode getEntityMode() { return EntityMode.POJO; }
From source file:org.eulerframework.web.core.extend.hibernate5.InExpressionX.java
License:Apache License
@Override public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) { final ArrayList<TypedValue> list = new ArrayList<TypedValue>(); final Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName); if (type.isComponentType()) { final CompositeType compositeType = (CompositeType) type; final Type[] subTypes = compositeType.getSubtypes(); for (Object value : values) { for (int i = 0; i < subTypes.length; i++) { final Object subValue = value == null ? null : compositeType.getPropertyValues(value, EntityMode.POJO)[i]; list.add(new TypedValue(subTypes[i], subValue)); }//from w w w .j a va 2 s . c o m } } else { for (Object value : values) { list.add(new TypedValue(type, value)); } } return list.toArray(new TypedValue[list.size()]); }
From source file:org.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.java
License:Apache License
@Override public Settings buildSettings(ServiceRegistry serviceRegistry) { Settings settings = super.buildSettings(serviceRegistry); settings.getEntityTuplizerFactory().registerDefaultTuplizerClass(EntityMode.POJO, GroovyAwarePojoEntityTuplizer.class); return settings; }
From source file:org.grails.orm.hibernate.cfg.DefaultGrailsDomainConfiguration.java
License:Apache License
@Override public Settings buildSettings(Properties props, ServiceRegistry serviceRegistry) throws HibernateException { Settings settings = super.buildSettings(props, serviceRegistry); settings.getEntityTuplizerFactory().registerDefaultTuplizerClass(EntityMode.POJO, GroovyAwarePojoEntityTuplizer.class); return settings; }
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 */// ww w. ja v a2 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); } }
From source file:org.granite.tide.hibernate.Hibernate35DataChangePublishListener.java
License:Open Source License
@SuppressWarnings("deprecation") private static Object getChange(EntityPersister persister, String entityName, Serializable id, Object entity) { Number version = (Number) persister.getVersion(entity, EntityMode.POJO); String uid = getUid(persister, entity); if (uid == null) return null; Object change = null;/*from w w w . j av a2 s. com*/ for (EntityUpdate du : DataContext.get().getDataUpdates()) { if (du.entity instanceof Change) { if (du.type == EntityUpdateType.UPDATE && ((Change) du.entity).getClassName().equals(entityName) && ((Change) du.entity).getId().equals(id)) { change = du.entity; break; } } else if (du.entity.getClass().getName().equals(entityName) && id.equals(persister.getIdentifier(entity, EntityMode.POJO))) { change = du.entity; break; } } if (change == null) { change = new Change(entityName, id, version, uid); DataContext.addUpdate(EntityUpdateType.UPDATE, change, entity, 1); } else if (change instanceof Change) ((Change) change).updateVersion(version); return change; }
From source file:org.granite.tide.hibernate.Hibernate35DataChangePublishListener.java
License:Open Source License
private static String getUid(EntityPersister persister, Object entity) { for (int i = 0; i < persister.getPropertyNames().length; i++) { if ("uid".equals(persister.getPropertyNames()[i])) return (String) persister.getPropertyValue(entity, i, EntityMode.POJO); }/*from www .j a v a 2s . co m*/ return null; }
From source file:org.jboss.tools.hibernate3_5.console.EntityPropertySource.java
License:Open Source License
public Object getPropertyValue(Object id) { Object propertyValue;//from ww w .j a v a2 s.co m if (id.equals(classMetadata.getIdentifierPropertyName())) { propertyValue = classMetadata.getIdentifier(reflectedObject, EntityMode.POJO); } else { try { propertyValue = classMetadata.getPropertyValue(reflectedObject, (String) id, EntityMode.POJO); } catch (HibernateException he) { propertyValue = HibernateConsoleMessages.EntityPropertySource_unable_to_resolve_property; if (classMetadata instanceof AbstractEntityPersister) { AbstractEntityPersister aep = (AbstractEntityPersister) classMetadata; EntityMetamodel emm = aep.getEntityMetamodel(); if (emm != null) { Integer idx = emm.getPropertyIndexOrNull((String) id); if (idx != null) { propertyValue = emm.getTuplizer(EntityMode.POJO).getPropertyValue(reflectedObject, idx); } } } } } if (propertyValue instanceof Collection<?>) { CollectionMetadata collectionMetadata = currentSession.getSessionFactory() .getCollectionMetadata(classMetadata.getEntityName() + "." + id); //$NON-NLS-1$ if (collectionMetadata != null) { propertyValue = new CollectionPropertySource((Collection<?>) propertyValue); } } return propertyValue; }