Reputation: 412
A database entity (a database contains table topics
):
@Entity
@Table(name = "topics")
public class Topic { ...
service method:
String queryString = "SELECT id FROM topics WHERE topic_name='" + topic_name + "'";
logger.debug(queryString); //SELECT id FROM topics WHERE topic_name='Chemistry'
Query query = session.createQuery(queryString); //an error is on this line
I get the error:
org.hibernate.hql.internal.ast.QuerySyntaxException: topics is not mapped
What is wrong with entity mapping?
Upvotes: 0
Views: 62
Reputation: 7624
Your query should be like this
String queryString = "SELECT id FROM Topic WHERE topic_name='" + topic_name + "'";
as your entity class is defined to be Topic.
Upvotes: 1