org.springframework.data.repository.core.EntityInformation Java Examples
The following examples show how to use
org.springframework.data.repository.core.EntityInformation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IgniteRepositoryFactory.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new AbstractEntityInformation<T, ID>(domainClass) { /** {@inheritDoc} */ @Override public ID getId(T entity) { return null; } /** {@inheritDoc} */ @Override public Class<ID> getIdType() { return null; } }; }
Example #2
Source File: SimpleKeyValueRepositoryUnitTests.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T, S> EntityInformation<T, S> getEntityInformationFor(Class<T> type) { PersistentEntity<T, ?> requiredPersistentEntity = (PersistentEntity<T, ?>) context .getRequiredPersistentEntity(type); return new PersistentEntityInformation<>(requiredPersistentEntity); }
Example #3
Source File: SimpleKeyValueRepositoryUnitTests.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@Test // DATACMNS-525 public void saveNewWithNumericId() { EntityInformation<WithNumericId, ?> ei = getEntityInformationFor(WithNumericId.class); SimpleKeyValueRepository<WithNumericId, ?> temp = new SimpleKeyValueRepository<>(ei, opsMock); WithNumericId withNumericId = new WithNumericId(); temp.save(withNumericId); verify(opsMock, times(1)).insert(eq(withNumericId)); }
Example #4
Source File: SimpleKeyValueRepositoryUnitTests.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@Before public void setUp() { this.context = new KeyValueMappingContext<>(); EntityInformation<Foo, String> ei = getEntityInformationFor(Foo.class); repo = new SimpleKeyValueRepository<>(ei, opsMock); }
Example #5
Source File: KeyValueRepositoryFactory.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
@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); }
Example #6
Source File: QuerydslKeyValueRepository.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
/** * Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation}, * {@link KeyValueOperations} and {@link EntityPathResolver}. * * @param entityInformation must not be {@literal null}. * @param operations must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations, EntityPathResolver resolver) { super(entityInformation, operations); Assert.notNull(resolver, "EntityPathResolver must not be null!"); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<>(path.getType(), path.getMetadata()); }
Example #7
Source File: SimpleKeyValueRepository.java From spring-data-keyvalue with Apache License 2.0 | 5 votes |
/** * Creates a new {@link SimpleKeyValueRepository} for the given {@link EntityInformation} and * {@link KeyValueOperations}. * * @param metadata must not be {@literal null}. * @param operations must not be {@literal null}. */ public SimpleKeyValueRepository(EntityInformation<T, ID> metadata, KeyValueOperations operations) { Assert.notNull(metadata, "EntityInformation must not be null!"); Assert.notNull(operations, "KeyValueOperations must not be null!"); this.entityInformation = metadata; this.operations = operations; }
Example #8
Source File: HazelcastRepositoryFactory.java From spring-data-hazelcast with Apache License 2.0 | 5 votes |
@Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { PersistentEntity<T, ?> entity = (PersistentEntity<T, ?>) keyValueOperations.getMappingContext() .getPersistentEntity(domainClass); Assert.notNull(entity, "Entity must not be 'null'."); return new HazelcastEntityInformation<>(entity); }
Example #9
Source File: FlushOnSaveRepositoryImpl.java From spring-data-examples with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private <S extends T> EntityInformation<Object, S> getEntityInformation(S entity) { Class<?> userClass = ClassUtils.getUserClass(entity.getClass()); if (entity instanceof AbstractPersistable<?>) { return new JpaPersistableEntityInformation(userClass, entityManager.getMetamodel()); } return new JpaMetamodelEntityInformation(userClass, entityManager.getMetamodel()); }
Example #10
Source File: FlushOnSaveRepositoryImpl.java From spring-data-examples with Apache License 2.0 | 5 votes |
/** * @param entity */ private <S extends T> void doSave(S entity) { EntityInformation<Object, S> entityInformation = getEntityInformation(entity); if (entityInformation.isNew(entity)) { entityManager.persist(entity); } else { entityManager.merge(entity); } }
Example #11
Source File: IgniteRepositoryFactory.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new AbstractEntityInformation<T, ID>(domainClass) { /** {@inheritDoc} */ @Override public ID getId(T entity) { return null; } /** {@inheritDoc} */ @Override public Class<ID> getIdType() { return null; } }; }
Example #12
Source File: CodelessDaoProxy.java From sca-best-practice with Apache License 2.0 | 5 votes |
@Transactional @Override public <T> T save(Class<T> clazz, T entity) { EntityInformation<T, ?> entityInformation = getEntityInformation(clazz); if (entityInformation.isNew(entity)) { entityManager.persist(entity); return entity; } else { return entityManager.merge(entity); } }
Example #13
Source File: IgniteRepositoryFactory.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new AbstractEntityInformation<T, ID>(domainClass) { @Override public ID getId(T entity) { return null; } @Override public Class<ID> getIdType() { return null; } }; }
Example #14
Source File: VaultRepositoryFactory.java From spring-vault with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { VaultPersistentEntity<T> entity = (VaultPersistentEntity<T>) this.operations.getMappingContext() .getPersistentEntity(domainClass); return new MappingVaultEntityInformation<>(entity); }
Example #15
Source File: SpannerRepositoryFactoryTests.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Test public void getEntityInformationTest() { EntityInformation<TestEntity, Key> entityInformation = this.spannerRepositoryFactory .getEntityInformation(TestEntity.class); assertThat(entityInformation.getJavaType()).isEqualTo(TestEntity.class); assertThat(entityInformation.getIdType()).isEqualTo(Key.class); TestEntity t = new TestEntity(); t.id = "a"; t.id2 = 3L; assertThat(entityInformation.getId(t)) .isEqualTo(Key.newBuilder().append(t.id).append(t.id2).build()); }
Example #16
Source File: SpannerRepositoryFactory.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { SpannerPersistentEntity<T> entity = (SpannerPersistentEntity<T>) this.spannerMappingContext .getPersistentEntity(domainClass); if (entity == null) { throw new MappingException(String.format( "Could not lookup mapping metadata for domain class %s!", domainClass.getName())); } return (EntityInformation<T, ID>) new SpannerPersistentEntityInformation<>( entity); }
Example #17
Source File: DatastoreRepositoryFactoryTests.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Test public void getEntityInformationTest() { EntityInformation<TestEntity, String> entityInformation = this.datastoreRepositoryFactory .getEntityInformation(TestEntity.class); assertThat(entityInformation.getJavaType()).isEqualTo(TestEntity.class); assertThat(entityInformation.getIdType()).isEqualTo(String.class); TestEntity t = new TestEntity(); t.id = "a"; assertThat(entityInformation.getId(t)).isEqualTo("a"); }
Example #18
Source File: ReactiveCosmosRepositoryFactory.java From spring-data-cosmosdb with MIT License | 5 votes |
@Override protected Object getTargetRepository(RepositoryInformation information) { final EntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType()); return getTargetRepositoryViaReflection(information, entityInformation, this.applicationContext); }
Example #19
Source File: DatastoreRepositoryFactory.java From spring-cloud-gcp with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { DatastorePersistentEntity entity = this.datastoreMappingContext .getPersistentEntity(domainClass); if (entity == null) { throw new MappingException( "Could not lookup mapping metadata for domain class: " + domainClass.getName()); } return new DatastorePersistentEntityInformation<>(entity); }
Example #20
Source File: CosmosRepositoryFactory.java From spring-data-cosmosdb with MIT License | 4 votes |
@Override protected Object getTargetRepository(RepositoryInformation information) { final EntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType()); return getTargetRepositoryViaReflection(information, entityInformation, this.applicationContext); }
Example #21
Source File: EntityInformationFacade.java From spring-content with Apache License 2.0 | 4 votes |
public EntityInformation getEntityInformation(Class<?> entityClass, EntityManager em) { return JpaEntityInformationSupport.getEntityInformation(entityClass, em); }
Example #22
Source File: CosmosRepositoryFactory.java From spring-data-cosmosdb with MIT License | 4 votes |
@Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainType) { return new CosmosEntityInformation<>(domainType); }
Example #23
Source File: ReactiveCosmosRepositoryFactory.java From spring-data-cosmosdb with MIT License | 4 votes |
@Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainType) { return new CosmosEntityInformation<>(domainType); }
Example #24
Source File: KeyValueRepositoryFactory.java From spring-data-keyvalue with Apache License 2.0 | 4 votes |
@Override protected Object getTargetRepository(RepositoryInformation repositoryInformation) { EntityInformation<?, ?> entityInformation = getEntityInformation(repositoryInformation.getDomainType()); return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation, keyValueOperations); }
Example #25
Source File: CosmosRepositoryFactoryUnitTest.java From spring-data-cosmosdb with MIT License | 4 votes |
@Test public void useMappingCosmosDBEntityInfoIfMappingContextSet() { final CosmosRepositoryFactory factory = new CosmosRepositoryFactory(dbTemplate, applicationContext); final EntityInformation<Person, String> entityInfo = factory.getEntityInformation(Person.class); assertTrue(entityInfo instanceof CosmosEntityInformation); }
Example #26
Source File: MyTitleRepositoryFactory.java From spring-data-hazelcast with Apache License 2.0 | 4 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) protected Object getTargetRepository(RepositoryInformation repositoryInformation) { EntityInformation<?, Serializable> entityInformation = getEntityInformation(repositoryInformation.getDomainType()); return new MyTitleRepositoryImpl(entityInformation, this.keyValueOperations); }
Example #27
Source File: MyTitleRepositoryImpl.java From spring-data-hazelcast with Apache License 2.0 | 4 votes |
public MyTitleRepositoryImpl(EntityInformation<T, ID> metadata, KeyValueOperations keyValueOperations) { super(metadata, keyValueOperations); }
Example #28
Source File: SimpleHazelcastRepository.java From spring-data-hazelcast with Apache License 2.0 | 4 votes |
public SimpleHazelcastRepository(EntityInformation<T, ID> metadata, KeyValueOperations operations) { super(metadata, operations); }
Example #29
Source File: ReactiveFirestoreRepositoryFactory.java From spring-cloud-gcp with Apache License 2.0 | 4 votes |
@Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> aClass) { return (EntityInformation<T, ID>) new FirestorePersistentEntityInformation<T>( (FirestorePersistentEntity<T>) this.firestoreMappingContext.getPersistentEntity(aClass)); }
Example #30
Source File: EbeanRepositoryFactory.java From spring-data-ebean with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new EbeanEntityInformation(this.ebeanServer, domainClass); }