Example usage for org.springframework.data.repository.core RepositoryMetadata getRepositoryInterface

List of usage examples for org.springframework.data.repository.core RepositoryMetadata getRepositoryInterface

Introduction

In this page you can find the example usage for org.springframework.data.repository.core RepositoryMetadata getRepositoryInterface.

Prototype

Class<?> getRepositoryInterface();

Source Link

Document

Returns the repository interface.

Usage

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 {//from   w  ww. j  ava 2 s.  com
        return new GenericRepositoryImpl(entityInformation, entityManager, namedQueryUtil); // custom
    }
}

From source file:egov.data.hibernate.repository.support.HibernateRepositoryFactory.java

@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {

    if (isQueryDslExecutor(metadata.getRepositoryInterface())) {
        // TODO/*from   w ww . ja  va 2s.  c  o  m*/
        throw new UnsupportedOperationException();
    } else {
        return SimpleHibernateRepository.class;
    }
}

From source file:com.sinosoft.one.data.jpa.repository.support.OneJpaRepositoryFactory.java

protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {

    if (isQueryDslExecutor(metadata.getRepositoryInterface())) {
        return QueryDslJpaRepository.class;
    } else {//from  w  w w  .j ava  2s.  co  m
        return SimpleJpaRepository.class;
    }
}

From source file:org.socialsignin.spring.data.dynamodb.repository.query.DynamoDBQueryMethod.java

public DynamoDBQueryMethod(Method method, RepositoryMetadata metadata) {
    super(method, metadata);
    this.method = method;
    this.scanEnabledForRepository = metadata.getRepositoryInterface().isAnnotationPresent(EnableScan.class);
    this.scanCountEnabledForRepository = metadata.getRepositoryInterface()
            .isAnnotationPresent(EnableScanCount.class);

}

From source file:cn.guoyukun.spring.jpa.repository.support.SimpleBaseRepositoryFactoryBean.java

@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    if (isBaseRepository(metadata.getRepositoryInterface())) {
        return SimpleBaseRepository.class;
    }/*from  w  w w.  ja  v  a  2s.com*/
    return super.getRepositoryBaseClass(metadata);
}

From source file:com.frank.search.solr.repository.support.SolrRepositoryFactory.java

@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    if (isQueryDslRepository(metadata.getRepositoryInterface())) {
        throw new IllegalArgumentException("QueryDsl Support has not been implemented yet.");
    }//  ww  w.  j  ava 2  s  . c  om
    return SimpleSolrRepository.class;
}

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);
        }//w  ww .  j  a v a  2s . 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 w w.  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;
}

From source file:cn.guoyukun.spring.jpa.repository.support.SimpleBaseRepositoryFactoryBean.java

@Override
protected Object getTargetRepository(RepositoryMetadata metadata) {
    Object object = null;/*from  ww  w .j  a  v a  2s  . c o m*/
    Class<?> repositoryInterface = metadata.getRepositoryInterface();
    LOG.debug("DAO? {}", repositoryInterface);
    if (isBaseRepository(repositoryInterface)) {
        object = doGetTargetRepository(metadata);
    } else {
        object = super.getTargetRepository(metadata);
    }
    return object;
}

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);

}