private static void fixCompositeIdentifierInMetaModel(SessionFactory sessionFactory, Class clazz) { ClassMetadata classMetadata = sessionFactory.getClassMetadata(clazz); if (classMetadata instanceof AbstractEntityPersister) { AbstractEntityPersister persister = (AbstractEntityPersister) classMetadata; EntityMetamodel model = persister.getEntityMetamodel(); IdentifierProperty identifier = model.getIdentifierProperty(); try { Field field = IdentifierProperty.class.getDeclaredField("hasIdentifierMapper"); field.setAccessible(true); field.set(identifier, true); field.setAccessible(false); } catch (Exception ex) { throw new SystemException("Attempt to fix entity meta model with hack failed, reason: " + ex.getMessage(), ex); } } }
public OBDynamicTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super(entityMetamodel, mappedEntity); log.debug("Created tuplizer for " + (mappedEntity.getMappedClass() != null ? mappedEntity.getMappedClass().getName() : mappedEntity.getEntityName())); persistentClass = mappedEntity; }
public PojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super( entityMetamodel, mappedEntity ); this.mappedClass = mappedEntity.getMappedClass(); this.proxyInterface = mappedEntity.getProxyInterface(); this.lifecycleImplementor = Lifecycle.class.isAssignableFrom( mappedClass ); this.validatableImplementor = Validatable.class.isAssignableFrom( mappedClass ); Iterator iter = mappedEntity.getPropertyClosureIterator(); while ( iter.hasNext() ) { Property property = (Property) iter.next(); if ( property.isLazy() ) { lazyPropertyNames.add( property.getName() ); } } String[] getterNames = new String[propertySpan]; String[] setterNames = new String[propertySpan]; Class[] propTypes = new Class[propertySpan]; for ( int i = 0; i < propertySpan; i++ ) { getterNames[i] = getters[i].getMethodName(); setterNames[i] = setters[i].getMethodName(); propTypes[i] = getters[i].getReturnType(); } if ( hasCustomAccessors || !Environment.useReflectionOptimizer() ) { optimizer = null; } else { // todo : YUCK!!! optimizer = Environment.getBytecodeProvider().getReflectionOptimizer( mappedClass, getterNames, setterNames, propTypes ); // optimizer = getFactory().getSettings().getBytecodeProvider().getReflectionOptimizer( // mappedClass, getterNames, setterNames, propTypes // ); } }
/** * Default constructor. * @param entityModel entity model class * @param persistentClass persistent class */ public PartCollectionEntityTuplizer(EntityMetamodel entityModel, PersistentClass persistentClass) { super(entityModel, persistentClass); propertyNames = new String[propertySpan]; Iterator propertiesIterator = persistentClass.getPropertyIterator(); int count = 0; while (propertiesIterator.hasNext()) { propertyNames[count++] = ((Property) propertiesIterator.next()).getName(); } }
public EntityMetamodel getEntityMetamodel() { return entityMetamodel; }
private void collectAttributeDefinitions( Map<String,AttributeDefinition> attributeDefinitionsByName, EntityMetamodel metamodel) { for ( int i = 0; i < metamodel.getPropertySpan(); i++ ) { final AttributeDefinition attributeDefinition = metamodel.getProperties()[i]; // Don't replace an attribute definition if it is already in attributeDefinitionsByName // because the new value will be from a subclass. final AttributeDefinition oldAttributeDefinition = attributeDefinitionsByName.get( attributeDefinition.getName() ); if ( oldAttributeDefinition != null ) { if ( LOG.isTraceEnabled() ) { LOG.tracef( "Ignoring subclass attribute definition [%s.%s] because it is defined in a superclass ", entityMetamodel.getName(), attributeDefinition.getName() ); } } else { attributeDefinitionsByName.put( attributeDefinition.getName(), attributeDefinition ); } } // see if there are any subclass persisters... final Set<String> subClassEntityNames = metamodel.getSubclassEntityNames(); if ( subClassEntityNames == null ) { return; } // see if we can find the persisters... for ( String subClassEntityName : subClassEntityNames ) { if ( metamodel.getName().equals( subClassEntityName ) ) { // skip it continue; } try { final EntityPersister subClassEntityPersister = factory.getEntityPersister( subClassEntityName ); collectAttributeDefinitions( attributeDefinitionsByName, subClassEntityPersister.getEntityMetamodel() ); } catch (MappingException e) { throw new IllegalStateException( String.format( "Could not locate subclass EntityPersister [%s] while processing EntityPersister [%s]", subClassEntityName, metamodel.getName() ), e ); } } }
@Override public EntityMetamodel getEntityMetamodel() { // TODO Auto-generated method stub return null; }
public OBTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super(entityMetamodel, mappedEntity); log.debug("Created tuplizer for " + (mappedEntity.getMappedClass() != null ? mappedEntity.getMappedClass().getName() : mappedEntity.getEntityName())); }
public GroovyAwarePojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super(entityMetamodel, mappedEntity); }
public EntityMetamodel getEntityMetamodel() { return null; }
public MyEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super( entityMetamodel, mappedEntity ); }
public AbstractEntityTuplizerImpl(EntityMetamodel entityMetamodel, PersistentClass persistentClass) { super(entityMetamodel, persistentClass); }
/** * Add the metadata for an entity. * * @param meta */ void addClass(ClassMetadata meta) { Class type = meta.getMappedClass(); String classKey = getEntityTypeName(type); HashMap<String, Object> cmap = new LinkedHashMap<String, Object>(); _typeList.add(cmap); cmap.put("shortName", type.getSimpleName()); cmap.put("namespace", type.getPackage().getName()); EntityMetamodel metaModel = ((EntityPersister) meta).getEntityMetamodel(); String superTypeName = metaModel.getSuperclass(); if (superTypeName != null) { ClassMetadata superMeta = _sessionFactory.getClassMetadata(superTypeName); if (superMeta != null) { Class superClass = superMeta.getMappedClass(); cmap.put("baseTypeName", getEntityTypeName(superClass)); } } String genType = "None"; if (meta instanceof EntityPersister) { EntityPersister entityPersister = (EntityPersister) meta; // multipart keys can never have an AutoGeneratedKeyType if (entityPersister.hasIdentifierProperty()) { IdentifierGenerator generator = entityPersister != null ? entityPersister.getIdentifierGenerator() : null; if (generator != null) { if (generator instanceof IdentityGenerator) { genType = "Identity"; } else if (generator instanceof Assigned || generator instanceof ForeignGenerator) { genType = "None"; } else { genType = "KeyGenerator"; } // TODO find the real generator } } } cmap.put("autoGeneratedKeyType", genType); String resourceName = pluralize(type.getSimpleName()); // TODO find the real name cmap.put("defaultResourceName", resourceName); _resourceMap.put(resourceName, classKey); ArrayList<HashMap<String, Object>> dataArrayList = new ArrayList<HashMap<String, Object>>(); cmap.put("dataProperties", dataArrayList); ArrayList<HashMap<String, Object>> navArrayList = new ArrayList<HashMap<String, Object>>(); cmap.put("navigationProperties", navArrayList); addClassProperties(meta, dataArrayList, navArrayList); }
public OptionAwarePojoEntityTuplizer(EntityMetamodel emm, EntityBinding eb) { super(emm, eb); }
public OptionAwarePojoEntityTuplizer(EntityMetamodel emm, PersistentClass pc) { super(emm, pc); }
/** * Retrieve the underlying entity metamodel instance... * *@return The metamodel */ public EntityMetamodel getEntityMetamodel();
/** * Constructs a new {@code ProxyPojoEntityTuplizer} instance. * * @param entityMetamodel * the entity meta model. * @param mappedEntity * the mapped entity. */ public DynamicPojoEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super(entityMetamodel, mappedEntity); fixPropertyAccessors(mappedEntity); }
/** * Default constructor. * @param entityModel entityMetaModel * @param persistentClass persistentClass */ public IsoCustomEntityTuplizer(EntityMetamodel entityModel, PersistentClass persistentClass) { super(entityModel, persistentClass); }