org.springframework.data.repository.PagingAndSortingRepository Java Examples
The following examples show how to use
org.springframework.data.repository.PagingAndSortingRepository.
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: AbstractIndexer.java From jkes with Apache License 2.0 | 6 votes |
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)); }); }
Example #2
Source File: JMSObjectComsumer.java From ElementVueSpringbootCodeTemplate with Apache License 2.0 | 6 votes |
/** * 更新对象的收藏数量 * @param objType * @param objId */ public void updateFavoriteCount(int objType, long objId) { PagingAndSortingRepository dao = findDao(objType); // 找到对应的对象 // 对象必须实现了可收藏,否则报错,可以把报错完善一下 Favoritable bizObj = (Favoritable) dao.findOne(objId); // 更新收藏数量字段 // FIXME 也可以在DAO上做,会少一些SQL int count = favoriteDao.countByObjTypeAndObjId(objType, objId); bizObj.setFavoriteCount(count); dao.save(bizObj); log.info("update obj [type:{}, id:{}] favorite count[{}] success.", objType, objId, count); }
Example #3
Source File: SpringDataJPAProcessor.java From quarkus with Apache License 2.0 | 5 votes |
@BuildStep void contributeClassesToIndex(BuildProducer<AdditionalIndexedClassesBuildItem> additionalIndexedClasses) { // index the Spring Data repository interfaces that extend Repository because we need to pull the generic types from it additionalIndexedClasses.produce(new AdditionalIndexedClassesBuildItem( Repository.class.getName(), CrudRepository.class.getName(), PagingAndSortingRepository.class.getName(), JpaRepository.class.getName(), QueryByExampleExecutor.class.getName())); }
Example #4
Source File: AbstractIndexer.java From jkes with Apache License 2.0 | 5 votes |
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); } }
Example #5
Source File: JMSObjectComsumer.java From ElementVueSpringbootCodeTemplate with Apache License 2.0 | 5 votes |
PagingAndSortingRepository<? extends BaseEntity, Long> findDao(int objType) { if (objType == ObjType.BLOG) { return blogDao; } throw new IllegalArgumentException("object type error: " + objType); }
Example #6
Source File: SecKillCommandConfig.java From seckill with Apache License 2.0 | 4 votes |
@Bean SecKillEventRepository secKillEventRepository( PagingAndSortingRepository<EventEntity, Integer> repository) { return new SecKillEventRepositoryImpl(repository); }
Example #7
Source File: FooService.java From tutorials with MIT License | 4 votes |
@Override protected PagingAndSortingRepository<Foo, Long> getDao() { return dao; }
Example #8
Source File: FooService.java From tutorials with MIT License | 4 votes |
@Override protected PagingAndSortingRepository<Foo, Long> getDao() { return dao; }
Example #9
Source File: FooService.java From tutorials with MIT License | 4 votes |
@Override protected PagingAndSortingRepository<Foo, Long> getDao() { return dao; }
Example #10
Source File: FooService.java From tutorials with MIT License | 4 votes |
@Override protected PagingAndSortingRepository<Foo, Long> getDao() { return dao; }
Example #11
Source File: DocFileInfoServiceImpl.java From wenku with MIT License | 4 votes |
@Override public PagingAndSortingRepository<DocFileInfo, String> getDao() { return docFileInfoDao; }
Example #12
Source File: VisitorServiceImpl.java From wenku with MIT License | 4 votes |
@Override public PagingAndSortingRepository<Visitor, String> getDao() { return visitorDao; }
Example #13
Source File: DocBaseInfoServiceImpl.java From wenku with MIT License | 4 votes |
@Override public PagingAndSortingRepository<DocBaseInfo, String> getDao() { return docBaseInfoDao; }
Example #14
Source File: UserServiceImpl.java From wenku with MIT License | 4 votes |
@Override public PagingAndSortingRepository<User, String> getDao() { return userDao; }
Example #15
Source File: SpringDataProviderBuilder.java From spring-data-provider with Apache License 2.0 | 4 votes |
public static <T> SpringDataProviderBuilder<T, Void> forRepository( PagingAndSortingRepository<T, ?> repository) { return new SpringDataProviderBuilder<>( (pageable, filter) -> repository.findAll(pageable), filter -> repository.count()); }
Example #16
Source File: SecKillEventRepositoryImpl.java From seckill with Apache License 2.0 | 4 votes |
public SecKillEventRepositoryImpl(PagingAndSortingRepository<EventEntity, Integer> repository) { this.repository = repository; }
Example #17
Source File: BaseServiceImpl.java From wenku with MIT License | votes |
public abstract PagingAndSortingRepository<T, ID> getDao();
Example #18
Source File: AbstractService.java From tutorials with MIT License | votes |
protected abstract PagingAndSortingRepository<T, Long> getDao();
Example #19
Source File: AbstractService.java From tutorials with MIT License | votes |
protected abstract PagingAndSortingRepository<T, Long> getDao();
Example #20
Source File: AbstractService.java From tutorials with MIT License | votes |
protected abstract PagingAndSortingRepository<T, Long> getDao();
Example #21
Source File: AbstractService.java From tutorials with MIT License | votes |
protected abstract PagingAndSortingRepository<T, Long> getDao();