Spring数据Jpa自定义存储库未找到属性
我正在尝试创建一个存储库,该存储库的方法不适合通常的Spring数据Jpa自定义存储库未找到属性,spring,spring-data-jpa,spring-data,Spring,Spring Data Jpa,Spring Data,我正在尝试创建一个存储库,该存储库的方法不适合通常的JpaRepository和@Query注释 我已经创建了一个自定义存储库界面: public interface CustomVoteRepository { List<VoteCountResult> countVotesForSession(); } 如果将自定义方法名称更改为votesForSessionCount,该怎么办?我想这样你就不会遇到方法名冲突。VoteCountResult在哪里?@我已经在帖子中添加了
JpaRepository
和@Query
注释
我已经创建了一个自定义存储库界面:
public interface CustomVoteRepository {
List<VoteCountResult> countVotesForSession();
}
如果将自定义方法名称更改为
votesForSessionCount
,该怎么办?我想这样你就不会遇到方法名冲突。VoteCountResult在哪里?@我已经在帖子中添加了它。我确实尝试了很多名称,但运气不好。刚刚尝试了您的建议,但仍然没有找到类型投票的SessionCount属性VotesFor代码>
@Repository
public class CustomVoteRepositoryImp implements CustomVoteRepository {
private JdbcTemplate jdbcTemplate;
public CustomVoteRepositoryImp(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Override
public List<VoteCountResult> countVotesForSession() {
return jdbcTemplate.query("SELECT video_id, COUNT(votes.id) FROM votes WHERE session_id=2 GROUP BY video_id",
new CustomRowMapper());
}
}
@Data
@AllArgsConstructor
public class VoteCountResult {
private String count;
private String title;
private String url;
}