Trying to run hql queries on intellij hibernate console

Answered

The project is all setup and when i import the project the persistence detects the hibernate structure.

opening the console for a particular main opens up the console. Where i try to do a simple query it fails with the following error.

hql> select id from Way
[2020-02-11 18:02:48] org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class []
[2020-02-11 18:02:48] java.lang.ClassNotFoundException:
[2020-02-11 18:02:48]   at java.base/java.lang.Class.forName0(Native Method)
[2020-02-11 18:02:48]   at java.base/java.lang.Class.forName(Class.java:398)
[2020-02-11 18:02:48]   at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:240)
[2020-02-11 18:02:48]   at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.loadDriverIfPossible(DriverManagerConnectionProviderImpl.java:200)
[2020-02-11 18:02:48]   at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildCreator(DriverManagerConnectionProviderImpl.java:156)
[2020-02-11 18:02:48]   at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:95)
[2020-02-11 18:02:48]   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
[2020-02-11 18:02:48]   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
[2020-02-11 18:02:48]   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
[2020-02-11 18:02:48]   at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
[2020-02-11 18:02:48]   at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
[2020-02-11 18:02:48]   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:111)
[2020-02-11 18:02:48]   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:234)
[2020-02-11 18:02:48]   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:206)
[2020-02-11 18:02:48]   at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
[2020-02-11 18:02:48]   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
[2020-02-11 18:02:48]   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
[2020-02-11 18:02:48]   in HibernateFacadeImpl$MyRemoteConfigurationImpl.buildSessionFactory(HibernateFacadeImpl.java:38) (no stack trace)


1
7 comments

What JDK and Hibernate versions do you use? Make sure to use versions that are compatible.

Please check also this thread about the same error and possible solutions: https://stackoverflow.com/q/53523684/2000323

If problem remains please provide a sample project to check.

0

Hi Andrey Dernov. 
Assigning a data source got me past this error.. But i am running into another issue with the mapping having duplicates.
I am guessing this is cause of the namingstratergy.. But i am unable to assign it the custom naming strategy we have in place.. as it doesnt show up in the list.

0

Are you getting DuplicateMappingException? You should check that you do not define multiply mappings for the same classes, e.g. via annotations and in xml files, see https://stackoverflow.com/a/25841157/2000323

0
The exact error. note! - i removed the name of the class/file..

[2020-02-14 10:05:15] java.lang.RuntimeException: org.hibernate.MappingException: Repeated column in mapping for entity: [the name removed] column: minus (should be mapped with insert="false" update="false")
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:709)
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:731)
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:727)
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:727)
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:727)
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:753)
[2020-02-14 10:05:15] at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:506)
[2020-02-14 10:05:15] at org.hibernate.mapping.JoinedSubclass.validate(JoinedSubclass.java:61)
[2020-02-14 10:05:15] at org.hibernate.cfg.Configuration.validate(Configuration.java:1358)
[2020-02-14 10:05:15] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1849)
[2020-02-14 10:05:15] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
[2020-02-14 10:05:15] in HibernateFacadeImpl$MyRemoteConfigurationImpl.buildSessionFactory(HibernateFacadeImpl.java:38) (no stack trace)
0

You need to check your code and annotations E.g. in this case: https://stackoverflow.com/q/21321814/2000323 the error was caused by mapping one column twice for the constraint with the same name (fid_module). Check forums for this error to look for more examples.

0

Hi Andrey.
I checked the code.. The problem is it should be taking on a different name due to our naming strategy . cause its being used as an embedded object.

0

If application works correctly but Hibernate console fails, please file a bug at https://youtrack.jetbrains.com/issues/IDEA with the sample project (can be attached privately) to reproduce.

0

Please sign in to leave a comment.