List of usage examples for org.springframework.data.repository.support Repositories getEntityInformationFor
@SuppressWarnings("unchecked") public <T, S> EntityInformation<T, S> getEntityInformationFor(Class<?> domainClass)
From source file:example.springdata.multistore.ApplicationConfigurationTest.java
@Test public void repositoriesAreAssignedToAppropriateStores() { Repositories repositories = new Repositories(context); assertThat(repositories.getEntityInformationFor(Customer.class), is(instanceOf(JpaEntityInformation.class))); assertThat(repositories.getEntityInformationFor(Order.class), is(instanceOf(MongoEntityInformation.class))); }
From source file:org.lightadmin.core.web.support.DynamicPersistentEntityResourceAssembler.java
/** * @see DATAREST-269 (https://jira.spring.io/browse/DATAREST-269) *//*from w w w . j av a 2 s . c o m*/ @Override public Link getSelfLinkFor(Object instance) { Assert.notNull(instance, "Domain object must not be null!"); Repositories repositories = repositories(this); Class instanceType = instance.getClass(); PersistentEntity<?, ?> entity = repositories.getPersistentEntity(instanceType); if (entity == null) { throw new IllegalArgumentException( String.format("Cannot create self link for %s! No persistent entity found!", instanceType)); } EntityInformation<Object, Serializable> entityInformation = repositories .getEntityInformationFor(instanceType); Serializable id = entityInformation.getId(instance); if (id == null) { return entityLinks(this).linkToCollectionResource(entity.getType()).withSelfRel(); } return entityLinks(this).linkToSingleResource(entity.getType(), id).withSelfRel(); }