thinker thinker - 1 year ago 66
Java Question

Hibernate says: table is not mapped -is it true?

A database entity (a database contains table


@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

What is wrong with entity mapping?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download