本文整理汇总了Java中org.springframework.data.mapping.PersistentEntity类的典型用法代码示例。如果您正苦于以下问题:Java PersistentEntity类的具体用法?Java PersistentEntity怎么用?Java PersistentEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PersistentEntity类属于org.springframework.data.mapping包,在下文中一共展示了PersistentEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MybatisMetamodelEntityInformation
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
/**
* Creates a new {@link AbstractEntityInformation} from the given domain class.
*
* @param domainClass must not be {@literal null}.
*/
protected MybatisMetamodelEntityInformation(PersistentEntity<T, ?> persistentEntity,
AuditorAware<?> auditorAware, AuditDateAware<?> auditDateAware, Class<T> domainClass) {
super(persistentEntity, auditorAware, auditDateAware, domainClass);
createdDateProperty = persistentEntity.getPersistentProperty(CreatedDate.class);
lastModifiedDateProperty = persistentEntity.getPersistentProperty(LastModifiedDate.class);
createdByProperty = persistentEntity.getPersistentProperty(CreatedBy.class);
lastModifiedByProperty = persistentEntity.getPersistentProperty(LastModifiedBy.class);
}
示例2: populateProperties
import org.springframework.data.mapping.PersistentEntity; //导入依赖的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);
}
示例3: SimpleCratePersistentProperty
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
public SimpleCratePersistentProperty(Field field, PropertyDescriptor propertyDescriptor,
PersistentEntity<?, CratePersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
super(field, propertyDescriptor, owner, simpleTypeHolder);
this.fieldNamingStrategy = INSTANCE;
String fieldName = getFieldName();
if(RESERVED_ID_FIELD_NAME.equals(fieldName)) {
throw new MappingException(format(RESERVED_ID, fieldName, owner.getType()));
}
if(RESERVED_VESRION_FIELD_NAME.equals(fieldName)) {
throw new MappingException(format(RESERVED_VERSION, fieldName, owner.getType()));
}
if(startsWithIgnoreCase(fieldName, "_")) {
throw new MappingException(format(STARTS_WITH_UNDERSCORE, fieldName, owner.getType()));
}
}
示例4: update
import org.springframework.data.mapping.PersistentEntity; //导入依赖的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);
}
示例5: delete
import org.springframework.data.mapping.PersistentEntity; //导入依赖的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);
}
示例6: MybatisEntityInformationSupport
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
/**
* Creates a new {@link AbstractEntityInformation} from the given domain class.
*
* @param auditDateAware
* @param domainClass must not be {@literal null}.
*/
protected MybatisEntityInformationSupport(
PersistentEntity<T, ?> persistentEntity,
AuditorAware<?> auditorAware,
AuditDateAware<?> auditDateAware, Class<T> domainClass) {
super(domainClass);
this.persistentEntity = persistentEntity;
this.auditorAware = auditorAware;
this.auditDateAware = auditDateAware;
}
示例7: getEntityInformation
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
public static <T, ID extends Serializable> MybatisEntityInformation<T, ID> getEntityInformation(MybatisMappingContext mappingContext,
AuditorAware<?> auditorAware,
AuditDateAware<?> auditDateAware,
Class<T> domainClass) {
Assert.notNull(domainClass);
PersistentEntity<T, ?> persistentEntity = (PersistentEntity<T, ?>) mappingContext.getPersistentEntity(domainClass);
if (Persistable.class.isAssignableFrom(domainClass)) {
return new MybatisPersistableEntityInformation(persistentEntity, auditorAware, auditDateAware, domainClass);
}
return new MybatisMetamodelEntityInformation<T, ID>(persistentEntity, auditorAware, auditDateAware, domainClass);
}
示例8: DefaultVaultTypeMapper
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
private DefaultVaultTypeMapper(@Nullable String typeKey,
TypeAliasAccessor<Map<String, Object>> accessor,
MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext,
List<? extends TypeInformationMapper> mappers) {
super(accessor, mappingContext, mappers);
this.typeKey = typeKey;
}
示例9: getPersistentProperty
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
public static PersistentProperty<?> getPersistentProperty(PersistentEntity<?,?> entity, String propertyName) {
PersistentProperty<?> prop = entity.getPersistentProperty(propertyName);
if (null == prop)
throw new ResourceNotFoundException();
return prop;
}
示例10: getContentPropertyDefinition
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
protected PersistentProperty<?> getContentPropertyDefinition(PersistentEntity<?, ?> persistentEntity, String contentProperty) {
PersistentProperty<?> prop = persistentEntity.getPersistentProperty(contentProperty);
if (null == prop)
throw new ResourceNotFoundException();
return prop;
}
示例11: buildProperties
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
private List<EntityProperty> buildProperties(Class<?> domainType) {
List<EntityProperty> properties = new ArrayList<>();
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) {
properties.add(factory.create(context));
}
}
return properties;
}
示例12: setupMocks
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
public void setupMocks() throws URISyntaxException {
configuration = mock(RepositoryRestConfiguration.class);
when(configuration.getBaseUri()).thenReturn(new URI("http://localhost:8080/"));
mappings = mock(ResourceMappings.class);
metaData = mock(ResourceMetadata.class);
when(metaData.getPath()).thenReturn(new Path("valueLists"));
PersistentEntity persistentEntity = mock(PersistentEntity.class);
when(persistentEntities.getPersistentEntity(any())).thenReturn(persistentEntity);
PersistentProperty persistentProperty = mock(PersistentProperty.class);
when(persistentEntity.getPersistentProperty(any(String.class))).thenReturn(persistentProperty);
when(entityLinks.linkFor(any())).thenReturn(BaseUriLinkBuilder.create(new URI("http://localhost:8080/")));
moduleRegistry = mock(ModuleRegistry.class);
when(moduleRegistry.getBaseUriForResource(anyString())).thenReturn(new RestUri("http://localhost:8080/valueLists"));
}
示例13: setupBasicMocks
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
@Before
public void setupBasicMocks() {
jacksonMetadata = new JacksonMetadata(new ObjectMapperBuilder().build(), SimpleClass.class);
persistentProperty = mock(PersistentProperty.class);
persistentEntity = mock(PersistentEntity.class);
when(persistentEntity.getType()).thenReturn(SimpleClass.class);
when(persistentProperty.getOwner()).thenReturn(persistentEntity);
}
示例14: BasicCloudantPersistentProperty
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
public BasicCloudantPersistentProperty(Field field, PropertyDescriptor propertyDescriptor, PersistentEntity<?, CloudantPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder, FieldNamingStrategy fieldNamingStrategy) {
super(field, propertyDescriptor, owner, simpleTypeHolder);
this.fieldNamingStrategy = fieldNamingStrategy == null ? PropertyNameFieldNamingStrategy.INSTANCE : fieldNamingStrategy;
if (isIdProperty() && getFieldName() != ID_FIELD_NAME) {
LOG.warn("Custom field name for id property is not supported!");
}
}
示例15: getEntityInformation
import org.springframework.data.mapping.PersistentEntity; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
PersistentEntity<T, ?> entity = (PersistentEntity<T, ?>) context.getRequiredPersistentEntity(domainClass);
return new PersistentEntityInformation<>(entity);
}