当前位置: 首页>>代码示例>>Java>>正文


Java PersistentProperty类代码示例

本文整理汇总了Java中org.springframework.data.mapping.PersistentProperty的典型用法代码示例。如果您正苦于以下问题:Java PersistentProperty类的具体用法?Java PersistentProperty怎么用?Java PersistentProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PersistentProperty类属于org.springframework.data.mapping包,在下文中一共展示了PersistentProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAuditDate

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
private void setAuditDate(PersistentProperty<?> property, T entity,
    Class<? extends Annotation> annotationType) {

  Object val = persistentEntity.getPropertyAccessor(entity).getProperty(property);
  if (null != val) {
    return;
  }

  if (null != auditDateAware) {
    persistentEntity.getPropertyAccessor(entity)
        .setProperty(property, auditDateAware.getCurrentDate());
    return;
  }

  Class<?> type = property.getRawType();
  if (Date.class.isAssignableFrom(type)) {
    persistentEntity.getPropertyAccessor(entity).setProperty(property, new Date());
  } else if (Long.class == type || long.class == type) {
    persistentEntity.getPropertyAccessor(entity)
        .setProperty(property, System.currentTimeMillis());
  } else {
    throw new IllegalArgumentException(
        "now we can not support " + type.getName() + " for " + annotationType.getName()
            + ", you can implement org.springframework.data.mybatis.domains.AuditDateAware interface as a spring bean.");
  }
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:27,代码来源:MybatisMetamodelEntityInformation.java

示例2: getContentPropertyType

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
public static Class<?> getContentPropertyType(PersistentProperty<?> prop) {
	Class<?> contentEntityClass = null;
	
	// null single-valued content property
	if (!PersistentEntityUtils.isPropertyMultiValued(prop)) {
		contentEntityClass = prop.getActualType();
	} 
	// null multi-valued content property
	else if (PersistentEntityUtils.isPropertyMultiValued(prop)) {
		if (prop.isArray()) {
			contentEntityClass = prop.getComponentType();
		}
		else if (prop.isCollectionLike()) {
			contentEntityClass = prop.getActualType();
		}
	}
	
	return contentEntityClass;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:20,代码来源:ContentPropertyUtils.java

示例3: setContentProperty

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
protected void setContentProperty(Object domainObj, PersistentProperty<?> property, String contentId, Object newValue) {

		PersistentPropertyAccessor accessor = property.getOwner().getPropertyAccessor(domainObj);
		Object contentPropertyObject = accessor.getProperty(property);
		if (contentPropertyObject == null) 
			return;
		else if (!PersistentEntityUtils.isPropertyMultiValued(property)) {
			accessor.setProperty(property, newValue);
		} else {
			// handle multi-valued
			if (property.isArray()) {
				throw new UnsupportedOperationException();
			} else if (property.isCollectionLike() && contentPropertyObject instanceof Set) {
				@SuppressWarnings("unchecked")
				Set<Object> contentSet = (Set<Object>)contentPropertyObject;
				Object oldValue = findContentPropertyObjectInSet(contentId, contentSet);
				contentSet.remove(oldValue);
				if (newValue != null)
					contentSet.add(newValue);
			}
		} 
	}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:23,代码来源:AbstractContentPropertyController.java

示例4: getContentProperty

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
protected Object getContentProperty(Object domainObj, PersistentProperty<?> property, String contentId) {

		PersistentPropertyAccessor accessor = property.getOwner().getPropertyAccessor(domainObj);
		Object contentPropertyObject = accessor.getProperty(property);

		// multi-valued property?
		if (PersistentEntityUtils.isPropertyMultiValued(property)) {
			if (property.isArray()) {
				throw new UnsupportedOperationException();
			} else if (property.isCollectionLike()) {
				contentPropertyObject = findContentPropertyObjectInSet(contentId, (Collection<?>)contentPropertyObject);
			}
		}
		
		if (contentPropertyObject == null) {
			throw new ResourceNotFoundException();
		}

		if (BeanUtils.hasFieldWithAnnotation(contentPropertyObject, ContentId.class)) {
			if (BeanUtils.getFieldWithAnnotation(contentPropertyObject, ContentId.class) == null) {
				throw new ResourceNotFoundException();
			}
		}
		
		return contentPropertyObject;
	}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:27,代码来源:AbstractContentPropertyController.java

示例5: populateProperties

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
private void populateProperties(Class<?> domainType, BusinessEntity entity) {
    Map<String, EntityProperty> properties = new HashMap<>();
    final PersistentEntity<?, ?> persistentEntity = persistentEntities.getPersistentEntity(domainType);
    JacksonMetadata jacksonMetadata = new JacksonMetadata(objectMapper, domainType);
    for (BeanPropertyDefinition definition : jacksonMetadata) {
        PersistentProperty<?> persistentProperty = persistentEntity.getPersistentProperty(definition.getInternalName());
        PropertyFactoryContext context = new PropertyFactoryContext(definition, jacksonMetadata, persistentProperty);
        PropertyFactory factory = getFactoryFor(context);
        if (factory != null) {
            EntityProperty property = factory.create(context);
            properties.put(definition.getInternalName(), property);
            if(property.isRequired()) {
                entity.getRequired().add(definition.getInternalName());
            }
        }
    }
    entity.setProperties(properties);
}
 
开发者ID:thomasletsch,项目名称:moserp,代码行数:19,代码来源:JsonSchemaBuilder.java

示例6: update

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
@Override
public void update(Object objectToUpdate) {
    PersistentEntity<?, ? extends PersistentProperty> entity = this.mappingContext.getPersistentEntity(ClassUtils
            .getUserClass(objectToUpdate));

    if (!entity.hasIdProperty()) {
        throw new InvalidDataAccessApiUsageException(String.format("Cannot determine id for type %s",
                ClassUtils.getUserClass(objectToUpdate)));
    }

    update((Serializable) entity.getIdentifierAccessor(objectToUpdate).getIdentifier(), objectToUpdate);
}
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:13,代码来源:TarantoolKeyValueTemplate.java

示例7: delete

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
@Override
public <T> T delete(T objectToDelete) {

    Class<T> type = (Class<T>) ClassUtils.getUserClass(objectToDelete);
    PersistentEntity<?, ? extends PersistentProperty> entity = this.mappingContext.getPersistentEntity(type);

    return delete((Serializable) entity.getIdentifierAccessor(objectToDelete).getIdentifier(), type);
}
 
开发者ID:saladinkzn,项目名称:spring-data-tarantool,代码行数:9,代码来源:TarantoolKeyValueTemplate.java

示例8: setPersistentEntityId

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
private <T> void setPersistentEntityId(T result, String id, Class<T> clazz) {

		if (mappingContext != null && clazz.isAnnotationPresent(Document.class)) {

			ElasticsearchPersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(clazz);
			PersistentProperty<?> idProperty = persistentEntity.getIdProperty();
			
			// Only deal with String because ES generated Ids are strings !
			if (idProperty != null && idProperty.getType().isAssignableFrom(String.class)) {
				persistentEntity.getPropertyAccessor(result).setProperty(idProperty, id);
			}
		}
	}
 
开发者ID:uckefu,项目名称:uckefu,代码行数:14,代码来源:UKResultMapper.java

示例9: findByColumnName

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
@Override
public MybatisPersistentProperty findByColumnName(final String columnName) {
    final MybatisPersistentProperty[] result = new MybatisPersistentProperty[1];
    doWithProperties(new SimplePropertyHandler() {
        @Override
        public void doWithPersistentProperty(PersistentProperty<?> pp) {
            MybatisPersistentProperty property = (MybatisPersistentProperty) pp;
            if (columnName.equalsIgnoreCase(property.getColumnName())) {
                result[0] = property;
                return;
            }
        }
    });
    return result[0];
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:16,代码来源:MybatisPersistentEntityImpl.java

示例10: getIdType

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
@Override
public Class<ID> getIdType() {
  if (null == persistentEntity) {
    return null;
  }

  PersistentProperty idProperty = persistentEntity.getIdProperty();
  if (null == idProperty) {
    return null;
  }
  return (Class<ID>) idProperty.getType();
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:13,代码来源:MybatisMetamodelEntityInformation.java

示例11: setCurrentAuditor

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
private void setCurrentAuditor(PersistentProperty<?> property, T entity) {
  Object val = persistentEntity.getPropertyAccessor(entity).getProperty(property);
  if (null != val) {
    return;
  }
  persistentEntity.getPropertyAccessor(entity)
      .setProperty(property, auditorAware.getCurrentAuditor());
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:9,代码来源:MybatisMetamodelEntityInformation.java

示例12: increaseVersion

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
@Override
public int increaseVersion(T entity) {
  PersistentProperty<?> versionProperty = persistentEntity.getVersionProperty();
  if (null == versionProperty) {
    return 0;
  }

  PersistentPropertyAccessor accessor = persistentEntity.getPropertyAccessor(entity);
  int newVer = (Integer) accessor.getProperty(versionProperty) + 1;
  accessor.setProperty(versionProperty, newVer);

  return newVer;
}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:14,代码来源:MybatisMetamodelEntityInformation.java

示例13: setVersion

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
@Override
public void setVersion(T entity, int version) {
  PersistentProperty<?> versionProperty = persistentEntity.getVersionProperty();
  if (null == versionProperty) {
    return;
  }
  persistentEntity.getPropertyAccessor(entity).setProperty(versionProperty, version);

}
 
开发者ID:hatunet,项目名称:spring-data-mybatis,代码行数:10,代码来源:MybatisMetamodelEntityInformation.java

示例14: getPersistentProperty

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
public static PersistentProperty<?> getPersistentProperty(PersistentEntity<?,?> entity, String propertyName) {
	
	PersistentProperty<?> prop = entity.getPersistentProperty(propertyName);
	if (null == prop)
		throw new ResourceNotFoundException();
	
	return prop;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:9,代码来源:PersistentEntityUtils.java

示例15: getContentPropertyDefinition

import org.springframework.data.mapping.PersistentProperty; //导入依赖的package包/类
protected PersistentProperty<?> getContentPropertyDefinition(PersistentEntity<?, ?> persistentEntity, String contentProperty) {
	PersistentProperty<?> prop = persistentEntity.getPersistentProperty(contentProperty);
	if (null == prop)
		throw new ResourceNotFoundException();
	
	return prop;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:8,代码来源:AbstractContentPropertyController.java


注:本文中的org.springframework.data.mapping.PersistentProperty类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。