Java 类org.springframework.data.repository.core.RepositoryMetadata 实例源码

项目:OperatieBRP    文件:CustomJpaRepositoryFactory.java   
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
protected SimpleJpaRepository<?, ?> getTargetRepository(
        final RepositoryMetadata metadata,
        final EntityManager entityManager) {
    final Class<?> repositoryInterface = metadata.getRepositoryInterface();
    final JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());

    if (isQueryDslSpecificExecutor(repositoryInterface)) {
        throw new IllegalArgumentException("QueryDSL interface niet toegestaan");
    }

    return isMaxedRepository(repositoryInterface)
            ? new CustomSimpleMaxedJpaRepository(entityInformation, entityManager)
            : isQuerycostRepository(repositoryInterface)
                    ? new CustomSimpleQuerycostJpaRepository(entityInformation, entityManager, maxCostsQueryPlan)
                    : new CustomSimpleJpaRepository(entityInformation, entityManager);
}
项目:spring-data-snowdrop    文件:ExtendingRepositoryFactorySupport.java   
public RepositoryFragments getExtensionFragments(RepositoryMetadata metadata) {
    Class<?> repositoryInterface = metadata.getRepositoryInterface();
    List<RepositoryFragment<?>> result = new ArrayList<>();

    Class<?> extensionInterface = getRepositoryExtensionInterface();

    for (Class<?> extendedInterface : repositoryInterface.getInterfaces()) {
        if (extensionInterface.isAssignableFrom(extendedInterface)) {
            result.add(createExtensionFragment(extendedInterface));
        }
    }

    if (result.isEmpty()) {
        return RepositoryFragments.empty();
    } else {
        return RepositoryFragments.from(result);
    }
}
项目:spring-data-jdbc-template    文件:JdbcTemplateRepositoryQuery.java   
JdbcTemplateQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
    super(method, metadata, factory);
    Query query = method.getAnnotation(Query.class);
    if (query == null) {
        this.query = null;
    } else {
        this.query = query.value();
    }

    this.singleColumn = method.getAnnotation(SingleColumn.class) != null;

    Mapper mapperOnMethod = method.getAnnotation(Mapper.class);
    Mapper mapperOnInterface = metadata.getRepositoryInterface().getAnnotation(Mapper.class);
    if (mapperOnMethod != null) {
        this.mapperClass = mapperOnMethod.value();
    } else if (mapperOnInterface != null) {
        this.mapperClass = mapperOnInterface.value();
    } else {
        this.mapperClass = null;
    }

    this.method = method;

}
项目:dubbox-solr    文件:SolrRepositoryFactory.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) {

    SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadata, entityInformationCreator);
    String namedQueryName = queryMethod.getNamedQueryName();

    SolrOperations solrOperations = selectSolrOperations(metadata);

    if (namedQueries.hasQuery(namedQueryName)) {
        String namedQuery = namedQueries.getQuery(namedQueryName);
        return new StringBasedSolrQuery(namedQuery, queryMethod, solrOperations);
    } else if (queryMethod.hasAnnotatedQuery()) {
        return new StringBasedSolrQuery(queryMethod, solrOperations);
    } else {
        return new PartTreeSolrQuery(queryMethod, solrOperations);
    }
}
项目:ignite    文件:IgniteRepositoryFactory.java   
/** {@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);
}
项目:richobjects    文件:RichObjectRepositoryFactory.java   
private ParameterizedType getRichObjectRepositoryType(final RepositoryMetadata metadata, final Type[] repositoryGenericInterfaces) {
    ParameterizedType repositoryType = null;
    for (Type repositoryGenericInterface : repositoryGenericInterfaces) {
        if (repositoryGenericInterface instanceof ParameterizedType) {
            final Type rawType = ((ParameterizedType) repositoryGenericInterface).getRawType();
            if (rawType instanceof Class &&
                    RichObjectRepository.class.isAssignableFrom((Class) rawType)) {

                repositoryType = (ParameterizedType) repositoryGenericInterface;
            }
        }
    }
    if (repositoryType == null) {
        throw new RuntimeException("Can't identify RichObjectRepository type from repository meta: " + metadata);
    }
    return repositoryType;
}
项目:spring-data-solr    文件:SolrRepositoryFactory.java   
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected Object getTargetRepository(RepositoryMetadata metadata) {

    SolrOperations operations = this.solrOperations;
    if (factory != null) {
        SolrTemplate template = new SolrTemplate(factory);
        template.setSolrCore(SolrServerUtils.resolveSolrCoreName(metadata.getDomainType()));
        addSchemaCreationFeaturesIfEnabled(template);
        template.afterPropertiesSet();
        operations = template;
    }

    SimpleSolrRepository repository = new SimpleSolrRepository(getEntityInformation(metadata.getDomainType()),
            operations);
    repository.setEntityClass(metadata.getDomainType());

    this.templateHolder.add(metadata.getDomainType(), operations);
    return repository;
}
项目:spring-data-solr    文件:SolrRepositoryFactory.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) {

    SolrQueryMethod queryMethod = new SolrQueryMethod(method, metadata, entityInformationCreator);
    String namedQueryName = queryMethod.getNamedQueryName();

    SolrOperations solrOperations = selectSolrOperations(metadata);

    if (namedQueries.hasQuery(namedQueryName)) {
        String namedQuery = namedQueries.getQuery(namedQueryName);
        return new StringBasedSolrQuery(namedQuery, queryMethod, solrOperations);
    } else if (queryMethod.hasAnnotatedQuery()) {
        return new StringBasedSolrQuery(queryMethod, solrOperations);
    } else {
        return new PartTreeSolrQuery(queryMethod, solrOperations);
    }
}
项目:spring-data-keyvalue    文件:KeyValueRepositoryFactory.java   
@Override
@SuppressWarnings("unchecked")
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
        NamedQueries namedQueries) {

    QueryMethod queryMethod = new QueryMethod(method, metadata, factory);

    Constructor<? extends KeyValuePartTreeQuery> constructor = (Constructor<? extends KeyValuePartTreeQuery>) ClassUtils
            .getConstructorIfAvailable(this.repositoryQueryType, QueryMethod.class, EvaluationContextProvider.class,
                    KeyValueOperations.class, Class.class);

    Assert.state(constructor != null,
            String.format(
                    "Constructor %s(QueryMethod, EvaluationContextProvider, KeyValueOperations, Class) not available!",
                    ClassUtils.getShortName(this.repositoryQueryType)));

    return BeanUtils.instantiateClass(constructor, queryMethod, evaluationContextProvider, this.keyValueOperations,
            this.queryCreator);
}
项目:spring-data-keyvalue    文件:SpelQueryEngineUnitTests.java   
private static SpelCriteria createQueryForMethodWithArgs(String methodName, Object... args) throws Exception {

        List<Class<?>> types = new ArrayList<>(args.length);

        for (Object arg : args) {
            types.add(arg.getClass());
        }

        Method method = PersonRepository.class.getMethod(methodName, types.toArray(new Class<?>[types.size()]));
        RepositoryMetadata metadata = mock(RepositoryMetadata.class);
        doReturn(method.getReturnType()).when(metadata).getReturnedDomainClass(method);

        PartTree partTree = new PartTree(method.getName(), method.getReturnType());
        SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(
                new QueryMethod(method, metadata, new SpelAwareProxyProjectionFactory()).getParameters(), args));

        return new SpelCriteria(creator.createQuery().getCriteria(), new StandardEvaluationContext(args));
    }
项目:javers    文件:OnDeleteAuditChangeHandler.java   
@Override
public void handle(RepositoryMetadata repositoryMetadata, Object domainObjectOrId) {
    Map<String, String> props = commitPropertiesProvider.provide();
    String author = authorProvider.provide();

    if (isIdClass(repositoryMetadata, domainObjectOrId)) {
        if (javers.findSnapshots(QueryBuilder.byInstanceId(domainObjectOrId, repositoryMetadata.getDomainType()).build()).size() == 0) {
            return;
        }

        javers.commitShallowDeleteById(author, instanceId(domainObjectOrId, repositoryMetadata.getDomainType()), props);
    } else if (isDomainClass(repositoryMetadata, domainObjectOrId)) {
        if (javers.findSnapshots(QueryBuilder.byInstance(domainObjectOrId).build()).size() == 0) {
            return;
        }

        javers.commitShallowDelete(author, domainObjectOrId, props);
    } else {
        throw new IllegalArgumentException("Domain object or object id expected");
    }
}
项目:spring-data-documentdb    文件:DocumentDbRepositoryFactory.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata,
                                    ProjectionFactory factory, NamedQueries namedQueries) {
    final DocumentDbQueryMethod queryMethod = new DocumentDbQueryMethod(method, metadata, factory);

    Assert.notNull(queryMethod, "queryMethod must not be null!");
    Assert.notNull(dbOperations, "dbOperations must not be null!");
    return new PartTreeDocumentDbQuery(queryMethod, dbOperations);

}
项目:tasfe-framework    文件:MybatisRepositoryQuery.java   
public MybatisRepositoryQuery(SqlSessionTemplate sqlSessionTemplate ,
                              Method method, RepositoryMetadata repositoryMetadata){
    this.sqlSessionTemplate = sqlSessionTemplate ;
    this.method = method ;
    this.repositoryMetadata = repositoryMetadata ;

    log.info("{}的领域类{}",repositoryMetadata.getRepositoryInterface().getName() , repositoryMetadata.getDomainType() );

    if(!mybatisMapperMap.containsKey(getMapperKey())){
        Object mapper = sqlSessionTemplate.getMapper(repositoryMetadata.getRepositoryInterface()) ;
        mybatisMapperMap.put(getMapperKey() , mapper) ;
    }

}
项目:tasfe-framework    文件:GenericQueryLookupStrategy.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repositoryMetadata, ProjectionFactory projectionFactory, NamedQueries namedQueries) {
    if (method.getAnnotation(MybatisQuery.class) != null) {
        log.info(repositoryMetadata.getRepositoryInterface().getName()+"."+method.getName()+" 为mybatis方法。 ");
        return new MybatisRepositoryQuery(sqlSessionTemplate , method , repositoryMetadata) ;
    } else {
        return jpaQueryLookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory,namedQueries);
    }
}
项目:spring-data-spanner    文件:SpannerRepositoryFactory.java   
@Override
  protected Class<?> getRepositoryBaseClass(RepositoryMetadata repositoryMetadata) {
    boolean isQueryDslRepository = QUERY_DSL_PRESENT
        && QueryDslPredicateExecutor.class.isAssignableFrom(repositoryMetadata.getRepositoryInterface());

//    return isQueryDslRepository ? QueryDslSpannerRepository.class : SimpleSpannerRepository.class;
    return SimpleSpannerRepository.class;

  }
项目:spring-data-snowdrop    文件:ExtendingRepositoryFactorySupport.java   
@Override
protected final RepositoryMetadata getRepositoryMetadata(Class<?> interfaze) {
    if (getRepositoryExtensionInterface().isAssignableFrom(interfaze)) {
        return getRepositoryExtensionMetadata(interfaze);
    } else {
        return getMainRepositoryMetadata(interfaze);
    }
}
项目:spring-data-snowdrop    文件:SnowdropRepositoryFactory.java   
private Class<?> getExactRepositoryBaseClass(RepositoryMetadata metadata) {
    if (SnowdropCrudRepository.class.isAssignableFrom(metadata.getRepositoryInterface())) {
        return SimpleCrudRepository.class;
    } else {
        return SimpleRepository.class;
    }
}
项目:spring-data-snowdrop    文件:SnowdropRepositoryFactory.java   
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    if (Integer.class.isAssignableFrom(metadata.getIdType()) || Long.class.isAssignableFrom(metadata.getIdType())
        || Double.class.isAssignableFrom(metadata.getIdType())) {
        return getExactRepositoryBaseClass(metadata);
    } else if (metadata.getIdType() == String.class) {
        return getExactRepositoryBaseClass(metadata);
    } else if (metadata.getIdType() == UUID.class) {
        return getExactRepositoryBaseClass(metadata);
    } else {
        throw new IllegalArgumentException("Unsupported ID type " + metadata.getIdType());
    }
}
项目:spring-data-snowdrop    文件:SnowdropRepositoryFactory.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory, NamedQueries namedQueries) {

    SnowdropQueryMethod queryMethod = new SnowdropQueryMethod(method, metadata, factory);
    String namedQueryName = queryMethod.getNamedQueryName();

    if (namedQueries.hasQuery(namedQueryName)) {
        String namedQuery = namedQueries.getQuery(namedQueryName);
        return new SnowdropStringQuery(queryMethod, snowdropOperations, namedQuery);
    } else if (queryMethod.hasAnnotatedQuery()) {
        return new SnowdropStringQuery(queryMethod, snowdropOperations, queryMethod.getAnnotatedQuery());
    }
    return new SnowdropPartQuery(queryMethod, snowdropOperations);
}
项目:OperatieBRP    文件:CustomJpaRepositoryFactory.java   
@Override
protected Class<?> getRepositoryBaseClass(final RepositoryMetadata metadata) {
    if (isMaxedRepository(metadata.getRepositoryInterface())) {
        return CustomSimpleMaxedJpaRepository.class;
    } else if (isQuerycostRepository(metadata.getRepositoryInterface())) {
        return CustomSimpleQuerycostJpaRepository.class;
    } else {
        return CustomSimpleJpaRepository.class;
    }
}
项目:spring-data-objectify    文件:ObjectifyQueryLookupStrategy.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
                                    NamedQueries namedQueries) {
    QueryMethod queryMethod = new QueryMethod(method, metadata, factory);

    return new ObjectifyRepositoryQuery(queryMethod);
}
项目:bootstrap    文件:RestRepositoryFactoryBean.java   
@Override
protected Class<?> getRepositoryBaseClass(final RepositoryMetadata metadata) {

    // The RepositoryMetadata can be safely ignored, it is used by the
    // JpaRepositoryFactory
    // to check for QueryDslJpaRepository's which is out of scope.
    return RestRepositoryImpl.class;
}
项目:spring-data-ebean    文件:EbeanQueryMethod.java   
/**
 * Creates a {@link EbeanQueryMethod}.
 *
 * @param method   must not be {@literal null}
 * @param metadata must not be {@literal null}
 */
public EbeanQueryMethod(Method method, RepositoryMetadata metadata, ProjectionFactory factory) {
  super(method, metadata, factory);

  Assert.notNull(method, "Method must not be null!");

  this.method = method;
}
项目:spring-data-mybatis    文件:MybatisRepositoryFactory.java   
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    if (isQueryDslExecutor(metadata.getRepositoryInterface())) {
        return QueryDslMybatisRepository.class;
    } else {
        return SimpleMybatisRepository.class;
    }
}
项目:spring-data-jpa-extra    文件:TemplateQueryLookupStrategy.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
        NamedQueries namedQueries) {
    if (method.getAnnotation(TemplateQuery.class) == null) {
        return jpaQueryLookupStrategy.resolveQuery(method, metadata, factory, namedQueries);
    }
    else {
        return new FreemarkerTemplateQuery(new JpaQueryMethod(method, metadata, factory, extractor), entityManager);
    }
}
项目:mongodb-aggregate-query-support    文件:AggregateMongoQuery.java   
/**
 * Creates a new {@link AbstractMongoQuery} from the given {@link MongoQueryMethod} and {@link MongoOperations}.
 *
 * @param method must not be {@literal null}.
 * @param projectionFactory - the projection factory
 */
@Autowired
public AggregateMongoQuery(Method method, RepositoryMetadata metadata, MongoOperations mongoOperations,
                           ProjectionFactory projectionFactory, MongoQueryExecutor queryExecutor) {
  super(new MongoQueryMethod(method, metadata, projectionFactory, mongoOperations.getConverter().getMappingContext()),
        mongoOperations);
  this.mongoOperations = mongoOperations;
  this.method = method;
  this.queryExecutor = queryExecutor;
}
项目:mongodb-aggregate-query-support    文件:AggregateQuerySupportingRepositoryFactory.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata repositoryMetadata,
                                    ProjectionFactory projectionFactory, NamedQueries namedQueries) {
  if (!isAggregateQueryAnnotated(method)) {
    return parentQueryLookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, namedQueries);
  }
  else {
    return new AggregateMongoQuery(method, repositoryMetadata, mongoOperations, projectionFactory, queryExecutor);
  }
}
项目:mongodb-aggregate-query-support    文件:AggregateQueryProvider2Test.java   
@Test(dataProvider = "queryMethods", expectedExceptions = {NullPointerException.class, IllegalArgumentException.class})
public void testCreateAggregateQuery(String methodName) throws Exception {
  AggregateQuerySupportingRepositoryFactory factory = new AggregateQuerySupportingRepositoryFactory(mongoOperations,
                                                                                                    queryExecutor);
  QueryLookupStrategy lookupStrategy = factory.getQueryLookupStrategy(CREATE_IF_NOT_FOUND, evaluationContextProvider);

  Method method = TestAggregateRepository22.class.getMethod(methodName);
  RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(TestAggregateRepository22.class);
  ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
  RepositoryQuery query = lookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, null);
  assertNotNull(query);
  Object object = query.execute(new Object[0]);
  assertNull(object);
}
项目:java-platform    文件:CustomRepositoryFactoryBean.java   
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    return isBaseRepository(metadata.getRepositoryInterface())
            ? (isTreeRepository(metadata.getRepositoryInterface()) ? TreeRepositoryImpl.class
                    : BaseRepositoryImpl.class)
            : super.getRepositoryBaseClass(metadata);
}
项目:strategy-spring-security-acl    文件:AclJpaRepositoryFactoryBean.java   
/**
 * @since Spring data JPA 1.10.0
 */
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata,
      ProjectionFactory factory, NamedQueries namedQueries) {
  QueryLookupStrategy queryLookupStrategy =
      Factory.super.getQueryLookupStrategy(key, evaluationContextProvider);

  RepositoryQuery query = queryLookupStrategy.resolveQuery(method, metadata, factory, namedQueries);
  return wrapQuery(method, metadata, query);
}
项目:strategy-spring-security-acl    文件:AclJpaRepositoryFactoryBean.java   
private RepositoryQuery wrapQuery(Method method, RepositoryMetadata metadata,
      RepositoryQuery query) {
  if (method.getDeclaredAnnotation(NoAcl.class) != null) {
    // no acl applied here
    return query;
  }
  if (query instanceof PartTreeJpaQuery) {
    query = new AclJpaQuery(method, query, metadata.getDomainType(), em, jpaSpecProvider);
  } else {
    logger.warn(
        "Unsupported query type for method '{}' > ACL Jpa Specification not installed: {}",
        method, query.getClass());
  }
  return query;
}
项目:genericdao    文件:MybatisRepositoryQuery.java   
public MybatisRepositoryQuery(SqlSessionTemplate sqlSessionTemplate ,
                              Method method, RepositoryMetadata repositoryMetadata){
    this.sqlSessionTemplate = sqlSessionTemplate ;
    this.method = method ;
    this.repositoryMetadata = repositoryMetadata ;

    log.info("{}的领域类{}",repositoryMetadata.getRepositoryInterface().getName() , repositoryMetadata.getDomainType() );

    if(!mybatisMapperMap.containsKey(getMapperKey())){
        Object mapper = sqlSessionTemplate.getMapper(repositoryMetadata.getRepositoryInterface()) ;
        mybatisMapperMap.put(getMapperKey() , mapper) ;
    }

}
项目:genericdao    文件:GenericQueryLookupStrategy.java   
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) {
    if (method.getAnnotation(MybatisQuery.class) != null) {
        log.info(metadata.getRepositoryInterface().getName()+"."+method.getName()+" 为mybatis方法。 ");
        return new MybatisRepositoryQuery(sqlSessionTemplate , method , metadata) ;
    } else {
        return jpaQueryLookupStrategy.resolveQuery(method, metadata, namedQueries);
    }
}
项目:g2    文件:DefaultRepositoryFactory.java   
@Override
protected <T, ID extends Serializable> JpaRepository<?, ?> getTargetRepository(
        RepositoryMetadata metadata, EntityManager entityManager) {

    JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata
            .getDomainType());
    return new GenericRepositoryImpl(entityInformation, entityManager); // custom
                                                                        // implementation
}
项目:spring-data-jpa-entity-graph    文件:EntityGraphJpaRepositoryFactory.java   
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
  if (isQueryDslExecutor(metadata.getRepositoryInterface())) {
    return EntityGraphQuerydslRepository.class;
  } else {
    return EntityGraphSimpleJpaRepository.class;
  }
}
项目:lobbycal    文件:CalendarDTRepositoryFactoryBean.java   
@SuppressWarnings({ "unchecked" })
protected Object getTargetRepository(RepositoryMetadata metadata) {
    JpaEntityInformation<T, Serializable> entityInformation = (JpaEntityInformation<T, Serializable>) getEntityInformation(metadata
            .getDomainType());
    return new CalendarDTRepositoryImpl<T, ID>(entityInformation,
            entityManager);
}
项目:dubbox-solr    文件:SolrRepositoryFactory.java   
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    if (isQueryDslRepository(metadata.getRepositoryInterface())) {
        throw new IllegalArgumentException("QueryDsl Support has not been implemented yet.");
    }
    return SimpleSolrRepository.class;
}
项目:dubbox-solr    文件:SolrRepositoryFactory.java   
private SolrOperations selectSolrOperations(RepositoryMetadata metadata) {
    SolrOperations ops = templateHolder.getSolrOperations(metadata.getDomainType());
    if (ops == null) {
        ops = solrOperations;
    }
    return ops;
}
项目:ignite    文件:IgniteRepositoryQuery.java   
/**
 * @param metadata Metadata.
 * @param qry Query.
 * @param mtd Method.
 * @param factory Factory.
 * @param cache Cache.
 */
public IgniteRepositoryQuery(RepositoryMetadata metadata, IgniteQuery qry,
    Method mtd, ProjectionFactory factory, IgniteCache cache) {
    type = metadata.getDomainType();
    this.qry = qry;
    this.cache = cache;

    this.metadata = metadata;
    this.mtd = mtd;
    this.factory = factory;

    returnStgy = calcReturnType(mtd, qry.isFieldQuery());
}
项目:ignite    文件:IgniteRepositoryFactory.java   
/** {@inheritDoc} */
@Override protected QueryLookupStrategy getQueryLookupStrategy(final QueryLookupStrategy.Key key,
    EvaluationContextProvider evaluationCtxProvider) {

    return new QueryLookupStrategy() {
        @Override public RepositoryQuery resolveQuery(final Method mtd, final RepositoryMetadata metadata,
            final ProjectionFactory factory, NamedQueries namedQueries) {

            final Query annotation = mtd.getAnnotation(Query.class);

            if (annotation != null) {
                String qryStr = annotation.value();

                if (key != Key.CREATE && StringUtils.hasText(qryStr))
                    return new IgniteRepositoryQuery(metadata,
                        new IgniteQuery(qryStr, isFieldQuery(qryStr), IgniteQueryGenerator.getOptions(mtd)),
                        mtd, factory, ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface())));
            }

            if (key == QueryLookupStrategy.Key.USE_DECLARED_QUERY)
                throw new IllegalStateException("To use QueryLookupStrategy.Key.USE_DECLARED_QUERY, pass " +
                    "a query string via org.apache.ignite.springdata.repository.config.Query annotation.");

            return new IgniteRepositoryQuery(metadata, IgniteQueryGenerator.generateSql(mtd, metadata), mtd,
                factory, ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface())));
        }
    };
}