• Register
0 votes
594 views

Problem :

I want to run the spring-boot application which uses thre hibernate via spring-jpa, but i am facing below error:

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:114)at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:82)at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:312)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:222)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:345)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:308)

 

6 5 3
7,540 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I also faced the similar issue in the recent past. And it was due to a invalid password provided. Also, I would like to say that your code seems to be very old-style code using the spring. You have already mentioned that you are trying to use the spring boot, which clearly means most of your things will be completely auto configured for you. The Hibernate dialect will also be auto selected based on your DB driver available on your classpath along with your valid credentials which can also be used to test your connection properly. If there is any issue with your connection then you will have to again face your same error. So you only need Three properties in your application.properties

# Replace with the valid connection string
spring.datasource.url=jdbc:mysql://localhost:xxxx/pdb1
# Replace with the valid credentials
spring.datasource.username=root
spring.datasource.password=

 If you follow above approach properly then you will be able to resolve your issue with minimum efforts on your side.

 

9 7 4
38,600 points
0 votes

Solution:

First remove all of your configuration Spring Boot will begin it for you. In case you truly require a SessionFactory instead of an EntityManagerFactory include a HibernateJpaSessionFactoryBean.

Ensure that you have an application.properties in your classpath and include the following properties.

spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/teste?charSet=LATIN1
spring.datasource.username=klebermo
spring.datasource.password=123

spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=create

In case you truly require access to a SessionFactory and that is originally for the similar data source, then you can do the following (which is further docmented here although for XML, not JavaConfig).

@Configuration        
public class HibernateConfig {

    @Bean
    public HibernateJpaSessionFactoryBean sessionFactory(EntityManagerFactory emf) {
         HibernateJpaSessionFactoryBean factory = new HibernateJpaSessionFactoryBean();
         factory.setEntityManagerFactory(emf);
         return factory;
    }
}

That method you have both an EntityManagerFactory and a SessionFactory.

Pretending you have a class with a main method with @EnableAutoConfiguration you don't require the @EnableTransactionManagement annotation, as that will be enabled by Spring Boot for you. A basic application class in the com.spring.app package must be enough.

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {


    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application.class, args);
    }

} 

Something like that must be enough to have all your classes (together with entities and Spring Data based repositories) detected.

I would also point out removing the commons-dbcp dependency as that would approve Spring Boot to configure the faster and more robust HikariCP implementation.

Including the following line to the properties file solve this problem at the time I had that error

spring.jpa.database=mysql

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 41 views
41 views
Problem : After executing spring boot with h2 database and JPA i am facing below error, any help: org.hibernate.tool.schema.spi.commandacceptanceexception: error executing ddl via jdbc statement
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 4.9K views
4.9K views
Problem : After executing spring boot with h2 database and JPA i am facing below error org.hibernate.tool.schema.spi.commandacceptanceexception: error executing ddl via jdbc statement
asked Nov 12, 2019 peterlaw 6.9k points
0 votes
1 answer 94 views
94 views
Problem : This is the error that is thrown when trying to run my web app: [INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of ... of the Datanucleus is no longer supported by your DataNucleus project I don't know what is missing in my app?
asked Dec 21, 2019 alecxe 7.5k points
0 votes
1 answer 47 views
47 views
Problem : any help with this: Consider defining a bean named 'entitymanagerfactory' in your configuration..
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 6.2K views
6.2K views
Problem : I am developing the application in Spring, using a Tomcat, Mysql5, Java8... My problem is that I cannot deploy it, due to the "required bean 'entityManagerFactory' not found" problem. I have developed my project with the coworkers but ... a bean named 'entityManagerFactory' that could not be found. Action: Consider defining a bean named 'entityManagerFactory' in your configuration.
asked Jan 25, 2020 jwilliam 3.9k points
0 votes
1 answer 2 views
2 views
Problem: Please help me to solve it. Spring-boot-starter-security
asked Apr 3 Ifra 24.4k points
0 votes
1 answer 3 views
3 views
Problem: Spring-boot-configuration-processor.
asked Mar 22 Dan phillip 4.8k points
0 votes
1 answer 13 views
13 views
Problem : I am a completely novice in the hibernate world and facing this error: Generationtarget encountered exception accepting command : error executing ddl via jdbc statement .
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 24 views
24 views
Problem: Why I got the error :javax.persistence.transactionrequiredexception: executing an update/delete query.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 19 views
19 views
Problem: HELP! I need help understanding this error: Error creating bean with name 'entitymanagerfactory' defined in class path resource.
asked Mar 6 Wafa Abu Yousef 6.1k points