本文整理匯總了Java中org.springframework.data.repository.core.RepositoryMetadata類的典型用法代碼示例。如果您正苦於以下問題:Java RepositoryMetadata類的具體用法?Java RepositoryMetadata怎麽用?Java RepositoryMetadata使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RepositoryMetadata類屬於org.springframework.data.repository.core包,在下文中一共展示了RepositoryMetadata類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTargetRepository
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
@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);
}
示例2: getExtensionFragments
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
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);
}
}
示例3: JdbcTemplateQueryMethod
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
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;
}
示例4: getTargetRepository
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
@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
}
示例5: resolveQuery
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的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);
}
}
示例6: getRepositoryMetadata
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
/** {@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);
}
示例7: getRichObjectRepositoryType
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
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;
}
示例8: getTargetRepository
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
@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;
}
示例9: resolveQuery
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的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);
}
示例10: createQueryForMethodWithArgs
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
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));
}
示例11: handle
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
@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");
}
}
示例12: resolveQuery
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的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);
}
示例13: MybatisRepositoryQuery
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
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) ;
}
}
示例14: resolveQuery
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的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);
}
}
示例15: getRepositoryBaseClass
import org.springframework.data.repository.core.RepositoryMetadata; //導入依賴的package包/類
@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;
}