各位前辈,第一次用SpringJPA。现在实体类有一个字段是这样的:
private String movie_id;
而我想通过这个字段排序,继承PagingAndSortingRepository后,代码为:
Sort sort = new Sort(Sort.Direction.DESC,"movie_id");
Pageable pageable = PageRequest.of(0,PAGE_LIMIT,sort);
Page<MovieInfo> movieInfopage = movieInfoRepository.findAll(pageable);
可是报错了:
org.springframework.data.mapping.PropertyReferenceException: No property movie found for type MovieInfo!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:92) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:356) ~[spring-data-commons-2.0.6.RELEASE.jar:2.0.6.RELEASE]
手动改movie_id 为 movieId后即可操作。
那肯定是框架无法识别下划线 ....
前辈们咋办!可以不用大改字段名么?