@Override protected void setMappingContext(MappingContext<?, ?> mappingContext) { super.setMappingContext(mappingContext); this.mappingContextConfigured = true; }
@Override public void setMappingContext(MappingContext<?, ?> mappingContext) { super.setMappingContext(mappingContext); }
@Override public void afterPropertiesSet() { Assert.state(entityManager != null, "EntityManager must not be null!"); super.afterPropertiesSet(); } }
@Override protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) { RepositoryFragments fragments = RepositoryFragments.empty(); boolean isQueryDslRepository = QUERY_DSL_PRESENT && ReactiveQuerydslPredicateExecutor.class.isAssignableFrom(metadata.getRepositoryInterface()); if (isQueryDslRepository) { MongoEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType(), metadata); fragments = fragments.append(RepositoryFragment.implemented(getTargetRepositoryViaReflection( ReactiveQuerydslMongoPredicateExecutor.class, entityInformation, operations))); } return fragments; }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); Assert.state(operations != null, "ReactiveElasticsearchOperations must not be null!"); if (!mappingContextConfigured) { setMappingContext(operations.getElasticsearchConverter().getMappingContext()); } } }
/** {@inheritDoc} */ @Override protected RepositoryMetadata getRepositoryMetadata(Class<?> repoItf) { Assert.notNull(repoItf, "Repository interface must be set."); Assert.isAssignable(IgniteRepository.class, repoItf, "Repository must implement IgniteRepository interface."); RepositoryConfig annotation = repoItf.getAnnotation(RepositoryConfig.class); Assert.notNull(annotation, "Set a name of an Apache Ignite cache using @RepositoryConfig annotation to map " + "this repository to the underlying cache."); Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite cache using @RepositoryConfig " + "annotation to map this repository to the underlying cache."); repoToCache.put(repoItf, annotation.cacheName()); return super.getRepositoryMetadata(repoItf); }
@Override public void setBeanClassLoader(ClassLoader classLoader) { super.setBeanClassLoader(classLoader); this.crudMethodMetadataPostProcessor.setBeanClassLoader(classLoader); }
@Override protected Object doExecute(final AbstractJpaQuery query, Object[] values) { if (!SurroundingTransactionDetectorMethodInterceptor.INSTANCE.isSurroundingTransactionActive()) { throw new InvalidDataAccessApiUsageException(NO_SURROUNDING_TRANSACTION); } Query jpaQuery = query.createQuery(values); // JPA 2.2 on the classpath if (streamMethod != null) { return ReflectionUtils.invokeMethod(streamMethod, jpaQuery); } // Fall back to legacy stream execution PersistenceProvider persistenceProvider = PersistenceProvider.fromEntityManager(query.getEntityManager()); CloseableIterator<Object> iter = persistenceProvider.executeQueryWithResultStream(jpaQuery); return StreamUtils.createStreamFromIterator(iter); } }
@Override @SuppressWarnings("unchecked") public Class<ID> getIdType() { if (this.entityMetadata.hasIdProperty()) { return super.getIdType(); } return fallbackIdType; } }
@Override protected final RepositoryFactorySupport createRepositoryFactory() { RepositoryFactorySupport factory = getFactoryInstance(operations); if (createIndexesForQueryMethods) { factory.addQueryCreationListener( new IndexEnsuringQueryCreationListener(collectionName -> operations.indexOps(collectionName))); } return factory; }
/** * Extract the {@link Predicate} representing the {@link Example}. * * @param root must not be {@literal null}. * @param cb must not be {@literal null}. * @param example must not be {@literal null}. * @return never {@literal null}. */ public static <T> Predicate getPredicate(Root<T> root, CriteriaBuilder cb, Example<T> example) { Assert.notNull(root, "Root must not be null!"); Assert.notNull(cb, "CriteriaBuilder must not be null!"); Assert.notNull(example, "Example must not be null!"); ExampleMatcher matcher = example.getMatcher(); List<Predicate> predicates = getPredicates("", cb, root, root.getModel(), example.getProbe(), example.getProbeType(), new ExampleMatcherAccessor(matcher), new PathNode("root", null, example.getProbe())); if (predicates.isEmpty()) { return cb.isTrue(cb.literal(true)); } if (predicates.size() == 1) { return predicates.iterator().next(); } Predicate[] array = predicates.toArray(new Predicate[0]); return matcher.isAllMatching() ? cb.and(array) : cb.or(array); }
@Override protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) { RepositoryFragments fragments = RepositoryFragments.empty(); if (QueryByExampleExecutor.class.isAssignableFrom(metadata.getRepositoryInterface())) { RedisMappingContext mappingContext = (RedisMappingContext) this.operations.getMappingContext(); RedisPersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(metadata.getDomainType()); MappingRedisEntityInformation<?, ?> entityInformation = new MappingRedisEntityInformation<>(persistentEntity); fragments = fragments.append(RepositoryFragment.implemented(QueryByExampleExecutor.class, getTargetRepositoryViaReflection(QueryByExampleRedisExecutor.class, entityInformation, operations))); } return fragments; }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); Assert.state(operations != null, "MongoTemplate must not be null!"); if (!mappingContextConfigured) { setMappingContext(operations.getConverter().getMappingContext()); } } }
@Override protected void setMappingContext(MappingContext<?, ?> mappingContext) { super.setMappingContext(mappingContext); this.mappingContextConfigured = true; }
/** {@inheritDoc} */ @Override protected RepositoryMetadata getRepositoryMetadata(Class<?> repoItf) { Assert.notNull(repoItf, "Repository interface must be set."); Assert.isAssignable(IgniteRepository.class, repoItf, "Repository must implement IgniteRepository interface."); RepositoryConfig annotation = repoItf.getAnnotation(RepositoryConfig.class); Assert.notNull(annotation, "Set a name of an Apache Ignite cache using @RepositoryConfig annotation to map " + "this repository to the underlying cache."); Assert.hasText(annotation.cacheName(), "Set a name of an Apache Ignite cache using @RepositoryConfig " + "annotation to map this repository to the underlying cache."); repoToCache.put(repoItf, annotation.cacheName()); return super.getRepositoryMetadata(repoItf); }
@Override protected final RepositoryFactorySupport createRepositoryFactory() { RepositoryFactorySupport factory = getFactoryInstance(operations); if (createIndexesForQueryMethods) { factory.addQueryCreationListener(new IndexEnsuringQueryCreationListener( collectionName -> IndexOperationsAdapter.blocking(operations.indexOps(collectionName)))); } return factory; }
@Override protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) { RepositoryFragments fragments = RepositoryFragments.empty(); boolean isQueryDslRepository = QUERY_DSL_PRESENT && QuerydslPredicateExecutor.class.isAssignableFrom(metadata.getRepositoryInterface()); if (isQueryDslRepository) { if (metadata.isReactiveRepository()) { throw new InvalidDataAccessApiUsageException( "Cannot combine Querydsl and reactive repository support in a single interface"); } MongoEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType(), metadata); fragments = fragments.append(RepositoryFragment.implemented( getTargetRepositoryViaReflection(QuerydslMongoPredicateExecutor.class, entityInformation, operations))); } return fragments; }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); Assert.state(operations != null, "ReactiveMongoOperations must not be null!"); if (!mappingContextConfigured) { setMappingContext(operations.getConverter().getMappingContext()); } } }
@Override protected void setMappingContext(MappingContext<?, ?> mappingContext) { super.setMappingContext(mappingContext); this.mappingContextConfigured = true; }
@Override protected RepositoryComposition.RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata) { RepositoryComposition.RepositoryFragments fragments = RepositoryComposition.RepositoryFragments.empty(); boolean isQueryDslRepository = QUERY_DSL_PRESENT && QuerydslPredicateExecutor.class.isAssignableFrom(metadata.getRepositoryInterface()); if (isQueryDslRepository) { if (metadata.isReactiveRepository()) { throw new InvalidDataAccessApiUsageException( "Cannot combine Querydsl and reactive repository support in a single interface"); } JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); Object querydslFragment = getTargetRepositoryViaReflection(QuerydslJpaPredicateExecutor.class, entityInformation, entityManager, entityPathResolver, crudMethodMetadataPostProcessor.getCrudMethodMetadata()); fragments = fragments.append(RepositoryFragment.implemented(querydslFragment)); } return fragments; }