0
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);
}

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?

carminePat
  • 159
  • 2
  • 5
  • 13

2 Answers2

2

The class name is Evento, not evento. So your queries should be

select count(e) from Evento e ...
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
0
@Query("select count(e) FROM event e WHERE e.status = 1 AND e.id_user = 2")
int countByStatus(String status, long id_user);
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • Consider adding a small explanation along with the code. SO discourages code only answers. – Alexei - check Codidact Feb 16 '17 at 13:15
  • Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* and *why* this solves the problem. Remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Feb 16 '17 at 13:29