Reputation: 213
I need to use a custom query for my application so this is my simplified code:
List<myDAO> findByName (
String Name
);
@Query("SELECT Company, count(Name) FROM my_table GROUP BY Company")
List<myDAO> getNamesOfCustom (
String Name
);
The first query works fine, the second is not, and I'm getting:
org.hibernate.hql.internal.ast.QuerySyntaxException: my_table is not mapped
I specified the table name in my DAO. Could the problem be with the table name if the first query is working?
Upvotes: 0
Views: 743
Reputation: 6233
You need to specify that you want a native SQL query:
@Query(
value = "SELECT Company, count(Name) FROM my_table GROUP BY Company",
nativeQuery = true)
Alternatively if you don't want a native query you should use the entity name, not the table name.
Upvotes: 1