當前位置: 首頁>>代碼示例>>Java>>正文


Java PagingAndSortingRepository類代碼示例

本文整理匯總了Java中org.springframework.data.repository.PagingAndSortingRepository的典型用法代碼示例。如果您正苦於以下問題:Java PagingAndSortingRepository類的具體用法?Java PagingAndSortingRepository怎麽用?Java PagingAndSortingRepository使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PagingAndSortingRepository類屬於org.springframework.data.repository包,在下文中一共展示了PagingAndSortingRepository類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: postConstruct

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
/**
 * Initialize all properties after instantiation
 */
@PostConstruct
public void postConstruct() {

	// Object Id Serializer
	if (!StringUtils.isEmpty(crudAdminProperties.getObjectidserializer())) {
		try {
			idSerializer = ((CrudAdminDefaultObjectIdSerializer) Class
					.forName(crudAdminProperties.getObjectidserializer()).newInstance());
		} catch (Exception ex) {
			LOGGER.error("Unable to create Object Id Serializer for class  "
					+ crudAdminProperties.getObjectidserializer());
		}
	}
	if (idSerializer == null) {
		idSerializer = new CrudAdminDefaultObjectIdSerializer();
	}

	// Map of PagingAndSortingRepository
	repositoryMap = new HashMap<>();
	if (repositories != null) {
		for (PagingAndSortingRepository<?, ?> repo : repositories) {
			CrudAdminRepository repoAdmin = CrudAdminUtils.getDomainClass(repo);
			repositoryMap.put(repoAdmin.getDomainTypeNameLowerCase(), repoAdmin);
		}
	}

}
 
開發者ID:qlefevre,項目名稱:crud-admin-spring-boot-starter,代碼行數:31,代碼來源:CrudAdminController.java

示例2: getDomainClass

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
public static CrudAdminRepository getDomainClass(PagingAndSortingRepository<?, ?> repo) {
	try {
		Class<?>[] classes = repo.getClass().getInterfaces();
		Class<?> repoClass = classes[0];
		DefaultRepositoryMetadata metadata = new DefaultRepositoryMetadata(repoClass);
		CrudAdminRepository repoAdmin = new CrudAdminRepository(repo, metadata);
		return repoAdmin;
	} catch (Exception ex) {
		throw new RuntimeException(ex);
	}
}
 
開發者ID:qlefevre,項目名稱:crud-admin-spring-boot-starter,代碼行數:12,代碼來源:CrudAdminUtils.java

示例3: init

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
protected void init() {
    Set<Class<?>> documentClasses = metadata.getAnnotatedDocuments();
    documentClasses.forEach(clazz -> {
        PagingAndSortingRepository repository = getRepositoryBean(clazz);
        addTask(new IndexTask() {
            @Override
            public Class<?> getDomainClass() {
                return clazz;
            }

            @Override
            public long count() {
                return repository.count();
            }

            @Override
            public Page<?> getData(Pageable pageable) {
                return repository.findAll(pageable);
            }
        });

        this.progress.put(clazz.getCanonicalName(), new IndexProgress(clazz, repository.count(), (long) 0));
    });
}
 
開發者ID:chaokunyang,項目名稱:jkes,代碼行數:25,代碼來源:AbstractIndexer.java

示例4: getRepositoryBean

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
private PagingAndSortingRepository getRepositoryBean(Class<?> entityClass) {
    String className = entityClass.getSimpleName();
    String repositoryBeanName = Character.toLowerCase(className.charAt(0)) + className.substring(1) + "Repository";
    String daoBeanName = Character.toLowerCase(className.charAt(0)) + className.substring(1) + "Dao";

    try {
        Object bean = this.contextSupport.getBean(repositoryBeanName);

        if(bean == null)
            bean = this.contextSupport.getBean(daoBeanName);

        if(bean == null) {
            RepositoryBean annotation = entityClass.getAnnotation(RepositoryBean.class);
            if(annotation != null) {
                if(StringUtils.hasText(annotation.beanName())) {
                    bean = this.contextSupport.getBean(annotation.beanName());
                    if (bean == null)
                        throw new NoAvailableRepositoryException("Couldn't find repository bean[" + annotation.beanName() + "]");

                    return (PagingAndSortingRepository) bean;
                }
                if(annotation.beanType() != void.class) {
                    bean = this.contextSupport.getBean(annotation.beanType());
                    if (bean == null)
                        throw new NoAvailableRepositoryException("Couldn't find repository bean[" + annotation.beanType() + "]");

                    return (PagingAndSortingRepository) bean;
                }
            }
        }

        if (bean == null)
            throw new NoAvailableRepositoryException(String.format("Couldn't find repository bean with name %s or %s", repositoryBeanName, daoBeanName));
        return (PagingAndSortingRepository) bean;
    } catch (InterruptedException e) {
        throw new JkesException("failed get bean: " + repositoryBeanName, e);
    }

}
 
開發者ID:chaokunyang,項目名稱:jkes,代碼行數:40,代碼來源:AbstractIndexer.java

示例5: run

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
/**
 * This method is part of CommandLineRunner and is called automatically by Spring.
 * @param args Main method arguments.
 */
public void run(String... args) {
  //Get all JaVers repositories.
  Map<String,Object> repositoryMap =
          applicationContext.getBeansWithAnnotation(JaversSpringDataAuditable.class);

  //For each one...
  for (Object object : repositoryMap.values()) {
    if (object instanceof PagingAndSortingRepository) {
      createSnapshots((PagingAndSortingRepository<?, ?>) object);
    } else if (object instanceof CrudRepository) {
      createSnapshots((CrudRepository<?, ?>) object);
    }
  }
}
 
開發者ID:OpenLMIS,項目名稱:openlmis-template-service,代碼行數:19,代碼來源:AuditLogInitializer.java

示例6: createSnapshots

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
private void createSnapshots(PagingAndSortingRepository<?, ?> repository) {
  Pageable pageable = new PageRequest(DEFAULT_PAGE_NUMBER, 2000);

  while (true) {
    Page<?> page = repository.findAll(pageable);

    if (!page.hasContent()) {
      break;
    }

    page.forEach(this::createSnapshot);

    pageable = pageable.next();
  }
}
 
開發者ID:OpenLMIS,項目名稱:openlmis-template-service,代碼行數:16,代碼來源:AuditLogInitializer.java

示例7: CrudAdminRepository

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
public CrudAdminRepository(PagingAndSortingRepository<?, ?> repository,
		DefaultRepositoryMetadata defaultRepositoryMetadata) {
	this.repository = repository;
	this.defaultRepositoryMetadata = defaultRepositoryMetadata;
}
 
開發者ID:qlefevre,項目名稱:crud-admin-spring-boot-starter,代碼行數:6,代碼來源:CrudAdminRepository.java

示例8: getRepository

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
public PagingAndSortingRepository<?, ?> getRepository() {
	return repository;
}
 
開發者ID:qlefevre,項目名稱:crud-admin-spring-boot-starter,代碼行數:4,代碼來源:CrudAdminRepository.java

示例9: getRepositoryObjectSerializable

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public PagingAndSortingRepository<Object, Serializable> getRepositoryObjectSerializable() {
	return ((PagingAndSortingRepository<Object, Serializable>) repository);
}
 
開發者ID:qlefevre,項目名稱:crud-admin-spring-boot-starter,代碼行數:5,代碼來源:CrudAdminRepository.java

示例10: setRepository

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
public void setRepository(PagingAndSortingRepository<?, ?> repository) {
	this.repository = repository;
}
 
開發者ID:qlefevre,項目名稱:crud-admin-spring-boot-starter,代碼行數:4,代碼來源:CrudAdminRepository.java

示例11: forRepository

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
public static <T> SpringDataProviderBuilder<T, Void> forRepository(
        PagingAndSortingRepository<T, ?> repository) {
    return new SpringDataProviderBuilder<>(
            (pageable, filter) -> repository.findAll(pageable),
            filter -> repository.count());
}
 
開發者ID:Artur-,項目名稱:spring-data-provider,代碼行數:7,代碼來源:SpringDataProviderBuilder.java

示例12: GetAllPagedTransaction

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
public GetAllPagedTransaction(Pageable page, PagingAndSortingRepository<T, ? extends Serializable> repo) {
	this.db = repo;
	this.page = page;
}
 
開發者ID:shilongdai,項目名稱:bookManager,代碼行數:5,代碼來源:GetAllPagedTransaction.java

示例13: convertAllFieldsToDto

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
private <F, T> List<T> convertAllFieldsToDto(
    PagingAndSortingRepository<F, UUID> repo, Function<F, T> converter) {
  return findAllFieldsFrom(repo)
      .map(converter)
      .collect(toList());
}
 
開發者ID:OpenLMIS,項目名稱:openlmis-stockmanagement,代碼行數:7,代碼來源:StockCardTemplateService.java

示例14: findAllFieldsFrom

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
private <F> Stream<F> findAllFieldsFrom(PagingAndSortingRepository<F, UUID> repo) {
  return stream(repo.findAll().spliterator(), false);
}
 
開發者ID:OpenLMIS,項目名稱:openlmis-stockmanagement,代碼行數:4,代碼來源:StockCardTemplateService.java

示例15: getDao

import org.springframework.data.repository.PagingAndSortingRepository; //導入依賴的package包/類
@Override
public PagingAndSortingRepository<User, String> getDao() {
    return userDao;
}
 
開發者ID:qjx378,項目名稱:wenku,代碼行數:5,代碼來源:UserServiceImpl.java


注:本文中的org.springframework.data.repository.PagingAndSortingRepository類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。