JpaRepository计数查询QuerySyntaxException实体未映射 [英] JpaRepository count query QuerySyntaxException entity is not mapped
问题描述
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 abstract 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]
I have this situation, and when i launch my project in apache Tomcat it generate Exception: - Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.lang.Long net.petrikainulainen.spring.social.signinmvc.user.repository.EventoRepository.countAll(long)! - Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: evento is not mapped [SELECT count(e) FROM evento e WHERE e.id_user= ?1] - Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: evento is not mapped [SELECT count(e) FROM evento e WHERE e.id_user= ?1]
任何人都可以帮助我,找到造成此异常的原因吗?
Can anyone help me please to find cause of this exception please?
推荐答案
类名称为Evento
,而不是evento
.所以您的查询应该是
The class name is Evento
, not evento
. So your queries should be
select count(e) from Evento e ...
这篇关于JpaRepository计数查询QuerySyntaxException实体未映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!