Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7893779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:13:16+00:00 2026-06-03T07:13:16+00:00

I use Hibernate (through JPA) configured by Spring and when I launch my application

  • 0

I use Hibernate (through JPA) configured by Spring and when I launch my application (war deployed on Tomcat 6), I get this error:

org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set 

It seems strange because I’ve set the hibernate dialect as follows:

p:databasePlatform="org.hibernate.dialect.MySQL5Dialect

For more information, here my full applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">


    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="com.mysql.jdbc.Driver"
          p:url="jdbc:mysql://localhost/room_management" p:username="root" p:password=""/>

    <bean id="entityManagerFactory"
          class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
          p:dataSource-ref="dataSource" p:persistenceUnitName="RoomManagement">
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
                  p:database="MYSQL"
                  p:databasePlatform="org.hibernate.dialect.MySQL5Dialect"
                  p:showSql="true"/>
        </property>
    </bean>

    <bean id="transactionManager"
          class="org.springframework.orm.jpa.JpaTransactionManager"
          p:entityManagerFactory-ref="entityManagerFactory"/>

    <context:annotation-config/>


    <context:component-scan base-package="com.parisdescartes.roommanagement.*"/>

    <tx:annotation-driven/>

</beans>

So, I decided to precise Hibernate Dialect within META-INF/persistence.xml file, and this time that works. Here how I precised it:

<properties>
            <property name="hibernate.dialect"
                      value="org.hibernate.dialect.MySQL5Dialect"/>
</properties>

Do you have an idea why Hibernate Dialect is not set using Spring configuration ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:13:18+00:00Added an answer on June 3, 2026 at 7:13 am

    Not sure why it won’t work with your configuration. Maybe something goes wrong with using the p: annotation. I’ll post my code (which works for my config) to try if it will fix your code! 🙂

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <property name="showSql" value="false"/>
                <property name="generateDdl" value="true"/>
                <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect"/>
            </bean>
        </property>
    </bean>
    

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our Spring application we use clustered Hibernate Search with ActiveMQ which sets up
My application runs on JPA/Hibernate, Spring and Wicket. I'm trying to convert our ORM
This week I've been trying to learn Spring, JBoss, Maven, JPA and Hibernate and
I am working on a Java application that will use some Hibernate (annotated by
I would like to use hibernate for persisting objects through web services and am
I was going through hibernate and situations when to use Criteria vs HQL and
I'm interested in porting an existing application which was written using Spring/Struts2/Hibernate to GAE.
currently I'm fooling around with a Spring setup. My goal is to use JPA
I use JPA inheritance with JOIN strategy (JPA2/Hibernate). I have an abstract general Event
What Spring annotation should I use for Hibernate DAO classes so they could be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.