org.hibernate.exception.SQLGrammarException: could not execute statement code example

Example 1: javax.persistence.persistenceexception: org.hibernate.exception.sqlgrammarexception: could not execute statement

Query query = this.entityManager.createNativeQuery(searchQuery, "TicketMapping");
//--------------------------------------------------------------------^^
//This should be the ObjectName.class

Example 2: javax.persistence.persistenceexception: org.hibernate.exception.sqlgrammarexception: could not execute statement

Query query = this.entityManager.createNativeQuery("YourQuery");
List<ObjectName> list = query.getResultList();
return list;

Example 3: javax.persistence.persistenceexception: org.hibernate.exception.sqlgrammarexception: could not execute statement

Query query = this.entityManager.createNativeQuery("YourQuery", ObjectName.class);

Tags:

Java Example