Thursday 13 October 2016

org.hibernate.hql.internal.ast.querysyntaxexception: "table_name" is not mapped Spring boot

Put your SampleWebJspApplication.java in pl.test package and execute the application.

It is recommended by Spring Boot to run your application from the root package and all your entities, controllers,DAO's and other service classes should be placed in child packages. This is not a hard and fast rule but it ensures all your subpackage annotated classes are scanned properly

In your case your User class is not scanned and Hibernate is not able to find the mapping for the same and eventually throwing the QuerySyntaxException when executing the from User query.

Currently Spring Boot will scan @Entity classes if they are placed in the same package or sub-packages where you specified the @SpringBootApplication annotation. Atleast, this is what I observed while developing spring boot apps lately.

If you do not want to move the location of the 

SampleApplication.java, then use 

@EntityScan(basePackages = "pl.test.model")

 annotation and this will fix the issue.

No comments:

Post a Comment

Spring boot with CORS

CORS (Cross-Origin Resource Sharing) errors occur when a web application running in a browser requests a resource from a different domain or...