I want to execute a simple native query, but it does not work:
@Autowired private EntityManager em; Query q = em.createNativeQuery(\"SELECT count(*) FROM my
You are calling setProperty instead of setParameter. Change your code to
setProperty
setParameter
Query q = em.createNativeQuery("SELECT count(*) FROM mytable where username = :username"); em.setParameter("username", "test"); (int) q.getSingleResult();
and it should work.