Category Archives: querysyntaxexception

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

Put your 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, then use 

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

 annotation and this will fix the issue.

74 total views, no views today