public interface EventoRepository extends JpaRepository<Evento, String>, JpaSpecificationExecutor<Evento> {
public Evento findById(String id);
public List<Evento> findByStatus(String status, Pageable page);
public List<Evento> findById_User(Long id_user,Pageable page);
@Query("select count(e) FROM evento e WHERE e.status = ?1 AND e.id_user = ?2")
int countByStatus(String status, long id_user);
@Query("SELECT count(e) FROM evento e WHERE e.id_user= ?1")
int countAll(long id_user);
@Query("SELECT count(e) FROM evento e WHERE e.status IS NOT = ?1 AND e.id_user = ?2")
int countBySospesi(String status, long id_user);
}
我遇到了这种情况,当我在 apache Tomcat 中启动我的项目时,它会生成异常: - 原因为:java.lang.IllegalArgumentException:方法公共(public)抽象 java.lang.Long net.petrikainulainen.spring.social.signinmvc.user.repository.EventoRepository.countAll(long) 的查询验证失败! - 引起原因:java.lang.IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:evento未映射[SELECT count(e) FROM evento e WHERE e.id_user= ?1] - 导致:org.hibernate.hql.internal.ast.QuerySyntaxException:evento未映射[SELECT count(e) FROM evento e WHERE e.id_user= ?1]
有人可以帮我找出此异常的原因吗?
最佳答案
类名称是 Evento
,而不是 evento
。所以你的查询应该是
select count(e) from Evento e ...
关于mysql - JpaRepository计数查询QuerySyntaxException实体未映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21629344/