本文整理汇总了Java中org.springframework.data.repository.core.NamedQueries类的典型用法代码示例。如果您正苦于以下问题:Java NamedQueries类的具体用法?Java NamedQueries怎么用?Java NamedQueries使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NamedQueries类属于org.springframework.data.repository.core包,在下文中一共展示了NamedQueries类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findNamedQueries
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
static NamedQueries findNamedQueries(Class<?> repositoryClass) {
try {
RepositoryConfigurationExtension config = new SnowdropRepositoryConfigExtension();
String location = config.getDefaultNamedQueryLocation();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(repositoryClass.getClassLoader());
ResourceArrayPropertyEditor editor = new ResourceArrayPropertyEditor(resolver, null);
editor.setAsText(location);
Resource[] resources = (Resource[]) editor.getValue();
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
pfb.setSingleton(false);
pfb.setLocations(resources);
pfb.setFileEncoding("UTF-8");
Properties properties = pfb.getObject();
return new PropertiesBasedNamedQueries(properties);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
示例2: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@Override
protected RepositoryQuery resolveQuery(EbeanQueryMethod method, EbeanServer ebeanServer, NamedQueries namedQueries) {
RepositoryQuery query = EbeanQueryFactory.INSTANCE.fromQueryAnnotation(method, ebeanServer, evaluationContextProvider);
if (null != query) {
return query;
}
String name = method.getNamedQueryName();
if (namedQueries.hasQuery(name)) {
return EbeanQueryFactory.INSTANCE.fromMethodWithQueryString(method, ebeanServer, namedQueries.getQuery(name),
evaluationContextProvider);
}
query = NamedEbeanQuery.lookupFrom(method, ebeanServer);
if (null != query) {
return query;
}
throw new IllegalStateException(
String.format("Did neither find a NamedQuery nor an annotated query for method %s!", method));
}
示例3: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
}
示例4: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
示例5: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@Override
protected RepositoryQuery resolveQuery(JdbcQueryMethod method, NamedQueries namedQueries) {
PartTree tree = new PartTree(method.getName(), method.getEntityInformation().getJavaType());
JdbcByNameRepositoryQueryCreator creator = new JdbcByNameRepositoryQueryCreator(method, tree, generator, template,
tableDescription, rowMapper);
return creator.createQuery();
}
示例6: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
示例7: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
}
示例8: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
示例9: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@Override
public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
NamedQueries namedQueries) {
QueryMethod queryMethod = new QueryMethod(method, metadata, factory);
return new ObjectifyRepositoryQuery(queryMethod);
}
示例10: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@Override
protected RepositoryQuery resolveQuery(MybatisQueryMethod method, NamedQueries namedQueries) {
try {
return new PartTreeMybatisQuery(context, sqlSessionTemplate, dialect, method);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
String.format("Could not create query metamodel for method %s!", method.toString()), e);
}
}
示例11: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
}
示例12: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
}
开发者ID:krraghavan,项目名称:mongodb-aggregate-query-support,代码行数:11,代码来源:AggregateQuerySupportingRepositoryFactory.java
示例13: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
/**
* @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);
}
示例14: resolveQuery
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
@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);
}
}
示例15: getQueryLookupStrategy
import org.springframework.data.repository.core.NamedQueries; //导入依赖的package包/类
/** {@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())));
}
};
}