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:方法公共抽象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/