tags:

views:

27

answers:

3

Hi,

I am novice in Hibernate technology. I have a Java project which uses Hibernate. When I run the project from Netbeans IDE the project runs fine without any issues.

However when I run the JAR file of the project from command prompt I get an exception

"org.hibernate.hql.ast.QuerySyntaxException:" XXXX is not mapped.

I have included all the Jars required for the execution of this project.Also I have imported javax.persistence.Entity.

Appreciate if you can help me out in this issue.

-Adish

A: 

You have to have .hbm.xml mapping objects to tables somewhere so Hibernate can read them. It's an ORM tool - JARs aren't sufficient.

duffymo
A: 

Most likely, the mapping files are not included into the generated .jar. Check their presence.

Put the mapping files in a folder included in the class path of the application. I don't use Netbeans, the feature might be called exported entries or build class path in the project settings.

Mapping files can be recognized easily, they end with the hbm.xml extension.

Samuel_xL
Thanks Samuel_xL and duffymo for your quick response.I am using hibernate annotations in my code.As mentioned I was not able to find any file with hbm.xml extension in the created JAR. So as per suggestion I will have hbm.xml mappings.Thank you for quick response.
Adish
A: 

However when I run the Jar file of the project from command prompt I get an exception "org.hibernate.hql.ast.QuerySyntaxException:" XXXX is not mapped.

The message is self explaining, you have somewhere a query that references a class that is considered as a non mapped class. Double check that:

  • XXXX is on the classpath.
  • XXXX is properly annotated.
  • XXXX is listed in the EntityManager configuration (or AnnotationConfiguration, what you're using is unclear).
Pascal Thivent