List of usage examples for org.springframework.data.repository.core RepositoryMetadata getDomainType
Class<?> getDomainType();
From source file:org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory.java
/** * Callback to create a {@link DynamoDBCrudRepository} instance with the given {@link RepositoryMetadata} * * @param <T>/*from w w w. jav a2s. co m*/ * @param <ID> * @param metadata * @see #getTargetRepository(RepositoryInformation) * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected <T, ID extends Serializable> DynamoDBCrudRepository<?, ?> getDynamoDBRepository( RepositoryMetadata metadata) { return new SimpleDynamoDBPagingAndSortingRepository(getEntityInformation(metadata.getDomainType()), dynamoDBOperations, getEnableScanPermissions(metadata)); }
From source file:org.jutge.joc.porra.repository.base.ExtendedMongoRepositoryFactory.java
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override//from ww w . j a v a 2s . c om protected Object getTargetRepository(final RepositoryMetadata metadata) { final MongoEntityInformation<?, Serializable> entityInformation = getEntityInformation( metadata.getDomainType()); return new ExtendedMongoRepositoryImpl(entityInformation, this.mongoOperations); }
From source file:org.springdata.ehcache.repository.config.EhcacheRepositoryFactory.java
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) protected Object getTargetRepository(RepositoryMetadata metadata) { EhcacheEntityInformation<?> entityInformation = getEntityInformationOverride(metadata.getDomainType()); return new SimpleEhcacheRepository(entityInformation, metadata.getRepositoryInterface(), ehcacheTemplate); }
From source file:name.marcelomorales.siqisiqi.openjpa.spring.OpenJpaRepositoryFactory.java
protected Object getTargetRepository(final RepositoryMetadata metadata) { return new OpenJpaRepositoryImpl<>((Class<T>) metadata.getDomainType(), entityManager, new OrmFinderSettings<T, I>() { @Override//from w w w . j a v a 2 s. co m public boolean returnsNullIfTermsAreNull() { final Class<?> repositoryInterface = metadata.getRepositoryInterface(); if (!repositoryInterface.isAnnotationPresent(OpenJpaSettings.class)) { return super.returnsNullIfTermsAreNull(); } final OpenJpaSettings annotation = repositoryInterface.getAnnotation(OpenJpaSettings.class); return annotation.returnsNullIfTermsAreNull(); } @Override public Iterable<Path<String>> getFullTexts(Root<T> from, Class<T> aClass) { final Class<?> repositoryInterface = metadata.getRepositoryInterface(); if (!repositoryInterface.isAnnotationPresent(OpenJpaSettings.class)) { return super.getFullTexts(from, aClass); } final OpenJpaSettings annotation = repositoryInterface.getAnnotation(OpenJpaSettings.class); String[] fulltexts = annotation.fullTexts(); List<Path<String>> paths = new ArrayList<>(fulltexts.length); for (String fulltext : fulltexts) { paths.add(from.<String>get(fulltext)); } return paths; } @Override public ComparisonStyle getComparisonStyle() { final Class<?> repositoryInterface = metadata.getRepositoryInterface(); if (!repositoryInterface.isAnnotationPresent(OpenJpaSettings.class)) { return new ComparisonStyle.Default(); } final OpenJpaSettings annotation = repositoryInterface.getAnnotation(OpenJpaSettings.class); final ComparisonStyle.Default aDefault = new ComparisonStyle.Default(); aDefault.setDisjunction(annotation.disjunction()); aDefault.setExcludeDefault(annotation.excludeDefault()); aDefault.setExcludeIdentity(annotation.excludeIdentity()); aDefault.setExcludeNull(annotation.excludeNull()); aDefault.setExcludeVersion(annotation.excludeVersion()); aDefault.setStringComparisonMode(annotation.stringComparisonMode()); return aDefault; } @Override public Path<I> countPath(Root<T> from, Class<T> aClass) { final Class<I> idType = (Class<I>) metadata.getIdType(); final SingularAttribute<T, I> declaredId = from.getModel().getDeclaredId(idType); return from.get(declaredId); } @Override public Attribute<?, ?>[] betweens(Root<T> from, Class<T> aClass) { final Class<?> repositoryInterface = metadata.getRepositoryInterface(); if (!repositoryInterface.isAnnotationPresent(OpenJpaSettings.class)) { return super.betweens(from, aClass); } final EntityType<T> model = from.getModel(); final OpenJpaSettings annotation = repositoryInterface.getAnnotation(OpenJpaSettings.class); String[] betweens = annotation.betweens(); Attribute[] attributes = new Attribute[betweens.length]; for (int i = 0; i < betweens.length; i++) { attributes[i] = model.getSingularAttribute(betweens[i]); } return attributes; } }); }
From source file:com.github.dactiv.orm.core.spring.data.jpa.factory.BasicJpaRepositoryFactory.java
@Override protected Object getTargetRepository(RepositoryMetadata metadata) { Class<?> repositoryInterface = metadata.getRepositoryInterface(); JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleJpaRepository<?, ?> repo = null; if (isQueryDslExecutor(repositoryInterface)) { repo = new QueryDslJpaRepository(entityInformation, entityManager); } else {// w w w . java 2 s . c o m repo = new JpaSupportRepository(entityInformation, entityManager); } repo.setLockMetadataProvider(LockModeRepositoryPostProcessor.INSTANCE.getLockMetadataProvider()); return repo; }
From source file:com.google.code.guice.repository.spi.CustomJpaRepositoryFactory.java
@Override protected JpaRepository<?, ?> getTargetRepository(RepositoryMetadata metadata, EntityManager entityManager) { Class<?> repositoryInterface = metadata.getRepositoryInterface(); JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); JpaRepository repo;//from w ww .j a va 2 s. c o m if (isQueryDslExecutor(repositoryInterface)) { repo = queryDslJpaRepositoryFactory.create(entityInformation, entityManager); } else { repo = batchRepositoryFactory.create(entityInformation, entityManager); } return repo; }
From source file:net.sf.gazpachoquest.repository.support.DefaultRepositoryFactory.java
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected <T, ID extends Serializable> SimpleJpaRepository<?, ?> getTargetRepository( final RepositoryMetadata metadata, final EntityManager entityManager) { Class<?> repositoryInterface = metadata.getRepositoryInterface(); JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); if (isQueryDslExecutor(repositoryInterface)) { return new QueryDslJpaRepository(entityInformation, entityManager); } else {// w w w . j a va2 s . c o m return new GenericRepositoryImpl(entityInformation, entityManager, namedQueryUtil); // custom } }
From source file:com.sinosoft.one.data.jpa.repository.support.OneRepositoryFactoryBeanSupport.java
@SuppressWarnings("unchecked") public EntityInformation<S, ID> getEntityInformation() { RepositoryMetadata repositoryMetadata = factory.getRepositoryMetadata(repositoryInterface); return (EntityInformation<S, ID>) factory.getEntityInformation(repositoryMetadata.getDomainType()); }
From source file:cn.guoyukun.spring.jpa.repository.support.SimpleBaseRepositoryFactoryBean.java
private Object doGetTargetRepository(RepositoryMetadata metadata) { Class<?> repositoryInterface = metadata.getRepositoryInterface(); JpaEntityInformation<M, ID> entityInformation = getEntityInformation((Class<M>) metadata.getDomainType()); SimpleBaseRepository<M, ID> repository = new SimpleBaseRepository<M, ID>(entityInformation, entityManager); SearchableQuery searchableQuery = AnnotationUtils.findAnnotation(repositoryInterface, SearchableQuery.class); if (searchableQuery != null) { String countAllQL = searchableQuery.countAllQuery(); if (!StringUtils.isEmpty(countAllQL)) { repository.setCountAllQL(countAllQL); }//from w ww. ja v a 2 s. c om String findAllQL = searchableQuery.findAllQuery(); if (!StringUtils.isEmpty(findAllQL)) { repository.setFindAllQL(findAllQL); } Class<? extends SearchCallback> callbackClass = searchableQuery.callbackClass(); if (callbackClass != null && callbackClass != SearchCallback.class) { repository.setSearchCallback(BeanUtils.instantiate(callbackClass)); } repository.setJoins(searchableQuery.joins()); } LOG.debug("?DAO {}", repository); return repository; }
From source file:com.sinosoft.one.data.jpa.repository.support.OneJpaRepositoryFactory.java
/** * Callback to create a {@link org.springframework.data.jpa.repository.JpaRepository} instance with the given {@link javax.persistence.EntityManager} * * @param <T>// w ww . j a va 2 s . c o m * @param <ID> * @param entityManager * @see #getTargetRepository(org.springframework.data.repository.core.RepositoryMetadata) * @return */ @SuppressWarnings({ "unchecked", "rawtypes" }) protected <T, ID extends Serializable> JpaRepository<?, ?> getTargetRepository(RepositoryMetadata metadata, EntityManager entityManager) { Class<?> repositoryInterface = metadata.getRepositoryInterface(); JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); SimpleJpaRepository<?, ?> repo = isQueryDslExecutor(repositoryInterface) ? new QueryDslJpaRepository(entityInformation, entityManager) : new SimpleJpaRepository(entityInformation, entityManager); repo.setLockMetadataProvider(lockModePostProcessor.getLockMetadataProvider()); return repo; }