Package org.hibernate.property

Examples of org.hibernate.property.Setter


    return getSetter( cls, propertyData.getBeanName(), propertyData.getAccessType() );
  }

  private static Setter getSetter(Class cls, String propertyName, String accessorType) {
    final Pair<Class, String> key = Pair.make( cls, propertyName );
    Setter value = SETTER_CACHE.get( key );
    if ( value == null ) {
      value = getAccessor( accessorType ).getSetter( cls, propertyName );
      // It's ok if two setters are generated concurrently
      SETTER_CACHE.put( key, value );
    }
View Full Code Here


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

    final 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 {
        final Object subObj = ReflectHelper.getDefaultConstructor( componentClass ).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

                                                     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

                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, 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

    public void mapToEntityFromMap(Object obj, Map data) {
        if (data == null || obj == null) {
            return;
        }

        Setter setter = ReflectionTools.getSetter(obj.getClass(), propertyData);
        setter.set(obj, data.get(propertyData.getName()), null);
    }
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

    public void mapToEntityFromMap(AuditConfiguration verCfg, Object obj, Map data, Object primaryKey, AuditReaderImplementor versionsReader, Number revision) {
        if (data == null || obj == null) {
            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

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

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

        try {
            Object subObj = ReflectHelper.getDefaultConstructor(getter.getReturnType()).newInstance();
            setter.set(obj, subObj, null);

            for (IdMapper idMapper : ids.values()) {
                idMapper.mapToEntityFromMap(subObj, data);
            }
        } catch (Exception 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.