Hibernate configuration in Eclipse with annotation-based mapping
vuser128 Feb 13, 2020 5:58 PMHello! I'm trying to set up a usable HQL console for an existing Java project with hibernate entity classes and a populated database. The project exclusively uses JPA annotation-based mapping and has no .hbm files, and has an "annotation-style" hibernate.cfg.xml file which lists the classes to be mapped. I've set up a hibernate configuration with the existing hibernate.cfg.xml file and a postgres connection. I've validated that the database connection works using the "Test Connection" button in the connection configuration window and it said "Ping succeeded". The configuration rebuilds successfully and I can open the HQL Editor and run queries. However, if I try to run an HQL query with a simple class name (e.g. "from Route" where Route is a mapped class in my hibernate.cfg.xml file that exists in the project) it says "org.hibernate.hql.internal.ast.QuerySyntaxException: Route is not mapped [from Route]". If I use the fully-qualified class name I don't get an error, but it doesn't load any results from the database either, there's just a little note saying "<multiple types>" and a blank box. When I run these queries, the log says:
Feb 13, 2020 3:04:42 PM org.hibernate.hql.internal.QuerySplitter concreteQueries
WARN: HHH000183: no persistent classes found for query class: from com.fully.qualified.name.Route
Also, nothing appears under the "Configuration" or "Session Factory" dropdowns under the hibernate config, although the screenshot on this page JBoss Tools - Hibernate Tools makes it look like that ought to contain a list of mapped entities? All the tables in the database do show up under the "Database" dropdown. If I try to generate the relationship mapping diagram (right-click on the hibernate config and select "Mapping Diagram") it says "no items or incorrect Hibernate Console Configuration state" (attached).
It seems like it's not detecting the annotation-based mappings correctly and therefore not mapping correctly between my query and the database? I tried checking "Annotations" instead of "Core" in the hibernate configuration window but it didn't change any of the symptoms I described above.
I'm new to Eclipse so apologies if there's something obvious I'm missing here. I've read through the instructions here: JBoss Tools - Develop an Application Using the Hibernate Tools, but they're mostly focused around creating a new project or generating entities from an existing database, which isn't what I want to do. Any guidance on what to try here would be appreciated!
Here are the relevant versions:
Eclipse version: 2019-12 (4.14.0)
Jboss tools version: 4.13.0.Final
Hibernate version: 4.3.6
-
incorrect_console_confi.png 2.6 KB
-
hibernate-configuration.png 81.6 KB