Package org.hibernate.property

Examples of org.hibernate.property.Setter


                value = versionsReader.getSessionImplementor().getFactory().getEntityPersister(referencedEntityName).
                        createProxy((Serializable)entityId, new ToOneDelegateSessionImplementor(versionsReader, entityClass, entityId, revision, verCfg));
            }
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
        setter.set(obj, value, null);
    }
View Full Code Here


                                                     AuditReaderImplementor versionsReader, Object primaryKey,
                                                     Number revision);

    public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data, Object primaryKey,
                                   AuditReaderImplementor versionsReader, Number revision) {
        Setter setter = ReflectionTools.getSetter(obj.getClass(),
                commonCollectionMapperData.getCollectionReferencingPropertyData());
        try {
            setter.set(obj, proxyConstructor.newInstance(getInitializor(verCfg, versionsReader, primaryKey, revision)), null);
        } catch (InstantiationException e) {
            throw new AuditException(e);
        } catch (IllegalAccessException e) {
            throw new AuditException(e);
        } catch (InvocationTargetException e) {
View Full Code Here

        } catch (NonUniqueResultException e) {
            throw new AuditException("Many versions results for one-to-one relationship: (" + owningEntityName +
                    ", " + owningReferencePropertyName + ")");
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
        setter.set(obj, value, null);
    }
View Full Code Here

            // (e.g. by applying <properties> tag).
            delegate.mapToEntityFromMap(verCfg, obj, data, primaryKey, versionsReader, revision);
            return;
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);

    // If all properties are null and single, then the component has to be null also.
    boolean allNullAndSingle = true;
    for (Map.Entry<PropertyData, PropertyMapper> property : delegate.getProperties().entrySet()) {
      if (data.get(property.getKey().getName()) != null || !(property.getValue() instanceof SinglePropertyMapper)) {
        allNullAndSingle = false;
        break;
      }
    }

    if (allNullAndSingle) {
      // single property, but default value need not be null, so we'll set it to null anyway
      setter.set(obj, null, null);     
    } else {
      // set the component
      try {
        Object subObj = ReflectHelper.getDefaultConstructor(
            Thread.currentThread().getContextClassLoader().loadClass(componentClassName)).newInstance();
        setter.set(obj, subObj, null);
        delegate.mapToEntityFromMap(verCfg, subObj, data, primaryKey, versionsReader, revision);
      } catch (Exception e) {
        throw new AuditException(e);
      }
    }
View Full Code Here

        Class entityClass = ReflectionTools.loadClass(entCfg.getEntityClassName());
        return new EntityInfo(entityClass, entityName, isRelationAudited);
    }

    protected void setPropertyValue(Object targetObject, Object value) {
        Setter setter = ReflectionTools.getSetter(targetObject.getClass(), propertyData);
        setter.set(targetObject, value, null);
    }
View Full Code Here

                                   AuditReaderImplementor versionsReader, Number revision) {
        if (data == null || obj == null) {
            return;
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
    Object value = data.get(propertyData.getName());
    // We only set a null value if the field is not primite. Otherwise, we leave it intact.
    if (value != null || !isPrimitive(setter, propertyData, obj.getClass())) {
          setter.set(obj, value, null);
    }
    }
View Full Code Here

                value = versionsReader.getSessionImplementor().getFactory().getEntityPersister(referencedEntityName).
                        createProxy((Serializable)entityId, new ToOneDelegateSessionImplementor(versionsReader, entityClass, entityId, revision, verCfg));
            }
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
        setter.set(obj, value, null);
    }
View Full Code Here

        Object value = data.get(propertyData.getName());
        if (value == null) {
            return false;
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
        setter.set(obj, value, null);

        return true;
    }
View Full Code Here

        if (objTo == null || objFrom == null) {
            return;
        }

        Getter getter = ReflectionTools.getGetter(objFrom.getClass(), propertyData);
        Setter setter = ReflectionTools.getSetter(objTo.getClass(), propertyData);
        setter.set(objTo, getter.get(objFrom), null);
    }
View Full Code Here

        if (data == null || obj == null) {
            return false;
        }

        Getter getter = ReflectionTools.getGetter(obj.getClass(), idPropertyData);
        Setter setter = ReflectionTools.getSetter(obj.getClass(), idPropertyData);

        try {
            Object subObj = ReflectHelper.getDefaultConstructor( getter.getReturnType() ).newInstance();

            boolean ret = true;
            for (IdMapper idMapper : ids.values()) {
                ret &= idMapper.mapToEntityFromMap(subObj, data);
            }

            if (ret) {
                setter.set(obj, subObj, null);
            }

            return ret;
        } catch (Exception e) {
            throw new AuditException(e);
View Full Code Here

TOP

Related Classes of org.hibernate.property.Setter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.