How does SpringJPA's Sort sort underlined fields?

seniors, use SpringJPA for the first time. Now the entity class has a field that looks like this:

    private String movie_id;

and I want to sort through this field. After inheriting PagingAndSortingRepository, the code is:

    Sort sort = new Sort(Sort.Direction.DESC,"movie_id");
    Pageable pageable = PageRequest.of(0,PAGE_LIMIT,sort);
    Page<MovieInfo> movieInfopage = movieInfoRepository.findAll(pageable);
    

but made a mistake:

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]

you can manually change movie_id to movieId.
that must be because the frame does not recognize the underscore.
what to do with the seniors! Can I not change the field name greatly?

Mar.05,2021

first of all, java field should use camel case, and should not use underscores in the first place. As for your question, according to the spring document, the underscore is a reserved field: "As we treat underscore as a reserved character we strongly advise to follow standard Java naming conventions (reserved not using underscores in property names but camel case instead)." Two solutions:
1.movie_id to movieId

  1. try two underscores escape drop underscore, Sort sort = new Sort (Sort.Direction.DESC, "movie__id");

through experiments, it is found that the fields in bean can be defined as humps, and the humps can be automatically transformed into underscores through the naming strategy of hibernate, and then what is needed in Sort is actually fields in bean. For example, the data defined as movieId, is automatically converted to movie_id, and then sorted according to the field of bean, that is, movieId.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8de01-118b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8de01-118b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?