Java Code Examples for org.springframework.data.repository.core.RepositoryMetadata#getRepositoryInterface()

The following examples show how to use org.springframework.data.repository.core.RepositoryMetadata#getRepositoryInterface() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultRepositoryFactory.java    From gazpachoquest with GNU General Public License v3.0 6 votes vote down vote up
@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 {
        return new GenericRepositoryImpl(entityInformation, entityManager, namedQueryUtil); // custom
    }
}
 
Example 2
Source File: DataTablesRepositoryFactoryBean.java    From spring-data-mongodb-datatables with Apache License 2.0 5 votes vote down vote up
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
    Class<?> repositoryInterface = metadata.getRepositoryInterface();
    if (DataTablesRepository.class.isAssignableFrom(repositoryInterface)) {
        return DataTablesRepositoryImpl.class;
    } else {
        return super.getRepositoryBaseClass(metadata);
    }
}
 
Example 3
Source File: QDataTablesRepositoryFactoryBean.java    From spring-data-jpa-datatables with Apache License 2.0 5 votes vote down vote up
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
  Class<?> repositoryInterface = metadata.getRepositoryInterface();
  if (QDataTablesRepository.class.isAssignableFrom(repositoryInterface)) {
    return QDataTablesRepositoryImpl.class;
  } else {
    return super.getRepositoryBaseClass(metadata);
  }

}
 
Example 4
Source File: DataTablesRepositoryFactoryBean.java    From spring-data-jpa-datatables with Apache License 2.0 5 votes vote down vote up
@Override
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
  Class<?> repositoryInterface = metadata.getRepositoryInterface();
  if (DataTablesRepository.class.isAssignableFrom(repositoryInterface)) {
    return DataTablesRepositoryImpl.class;
  } else {
    return super.getRepositoryBaseClass(metadata);
  }
}
 
Example 5
Source File: JooqJpaRepositoryFactory.java    From blog-examples with Apache License 2.0 5 votes vote down vote up
protected <T, ID extends Serializable> JpaRepository<?, ?> getTargetRepository(
		RepositoryMetadata metadata, EntityManager entityManager) {

	Class<?> repositoryInterface = metadata.getRepositoryInterface();
	JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType());

	SimpleJpaRepository<?, ?> repo;
	if (JooqQueryExecutor.class.isAssignableFrom(repositoryInterface)) {
		repo = new JooqJpaRepository(entityInformation, entityManager, jooq);
	} else {
		repo = new SimpleJpaRepository(entityInformation, entityManager);
	}
	repo.setLockMetadataProvider(LockModeRepositoryPostProcessor.INSTANCE.getLockMetadataProvider());
	return repo;
}
 
Example 6
Source File: SimpleBaseRepositoryFactoryBean.java    From es with Apache License 2.0 5 votes vote down vote up
protected Object getTargetRepository(RepositoryMetadata metadata) {
    Class<?> repositoryInterface = metadata.getRepositoryInterface();

    if (isBaseRepository(repositoryInterface)) {

        JpaEntityInformation<M, ID> entityInformation = getEntityInformation((Class<M>) metadata.getDomainType());
        SimpleBaseRepository 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);
            }
            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());

        }

        return repository;
    }
    return super.getTargetRepository(metadata);
}
 
Example 7
Source File: DynamoDBRepositoryFactory.java    From spring-data-dynamodb with Apache License 2.0 4 votes vote down vote up
protected EnableScanPermissions getEnableScanPermissions(RepositoryMetadata metadata) {
	return new EnableScanAnnotationPermissions(metadata.getRepositoryInterface());
}