JPA Console 'hibernate.dialect' not set error during a query to Sql Server table

Answered

I've configured Intellij to connect to a Sql Server DB. The connection works fine and if I try to get results by using a Rest API all works!
The problem is when I try to test queries using the JPA Console. I've this error back

[2018-12-11 12:24:05] org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
[2018-12-11 12:24:05] java.lang.RuntimeException: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
etc...

The configuration of application.properties is:

spring.jpa.hibernate.ddl-auto = validate
spring.jpa.show-sql=true
spring.datasource.url=jdbc:sqlserver://localhost;databaseName=db-chklist;integratedSecurity=true;
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.SQLServerDialect

5 comments
Comment actions Permalink

I am experiencing the same case. Application and API works, while the JPA console in intellij giving same error message all the time.

Andrey 's solution doesnt solve it.

Using application.yml as my app config. I didn't create persistence.xml, and it didn't work either.

And I am sure I have assigned the data source and entityManagerFactory. and the connection is live.

SQL can be executed but HQL not.

org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

java.lang.RuntimeException: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
[2019-10-18 19:20:09] at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100)
[2019-10-18 19:20:09] at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54)
[2019-10-18 19:20:09] at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:137)
[2019-10-18 19:20:09] at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35)
[2019-10-18 19:20:09] at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88)
[2019-10-18 19:20:09] at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:259)
[2019-10-18 19:20:09] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:233)
[2019-10-18 19:20:09] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
[2019-10-18 19:20:09] at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51)
[2019-10-18 19:20:09] at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94)
[2019-10-18 19:20:09] at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:242)
[2019-10-18 19:20:09] at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210)
[2019-10-18 19:20:09] at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352)
[2019-10-18 19:20:09] at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111)
[2019-10-18 19:20:09] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:861)
[2019-10-18 19:20:09] at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:888)
[2019-10-18 19:20:09] at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)

 

I do not understand.

0
Comment actions Permalink

The exception above looks like an authorization error, see https://youtrack.jetbrains.com/issue/IDEA-164233 for details

0
Comment actions Permalink

Data source is assigned.

And SQL console works.

only the JPA/hibernate console has this exception.

0
Comment actions Permalink

Exception above:
-it can be caused by data source is not being assigned to a PersistenceUnit in the PersistenceView - see IDEA-164233, IDEA-161766
-it can be caused by password is being absent - see IDEA-206638
-it is important also to open a new console after assigning etc because the old one is opened with the old properties
-today I've got this exception by having one more connection to the same db (should be the Lock error, but appeared this one)
and also I've met the case of not working completion in consoles in EAP build. I've just re-opened the project and the problem disappeared.
So, in our nowadays eaps just re-opening the project can solve the problem. Unfortunately.

I've tried to reproduce the problem in one of my spring boot test projects which are without persistence.xml, but it works ok for me.
Tried for diff spring boot versions - works ok.

I'd recommend do the following
-close all the consoles and stop all the connections to the db from idea
-build the project (I do usually re-build)
-check, that db credentials saved and work ok in the Database view (connect/disconnect to db)
in case of persistence.xml presence - check credential correctness there.
-check that resolve from an entity in the code works ok to the db table
-check that this db is assigned in the Persistence view
-run a query in a JPA/Hibernate console

If it doesn't help could you please provide us with a simple example project?

0

Please sign in to leave a comment.