lior
lior

Reputation: 1187

How to configure hibernate.dialect in my context.xml

this is the relevant part from my context.xml file:

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="com.netomedia.model"/>  
<property name="jpaProperties">
    <props>
        <prop key="hibernate.hbm2ddl.auto">update</prop>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
    </props>
</property>
<!-- <property name="persistenceUnitName" value="punit"/> -->
<property name="dataSource" ref="dataSource"/>
<property name="jpaDialect">
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaVendorAdapter">
    <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="database" value="MYSQL"/>
        <!-- <property name="databasePlatform" value="${hibernate.dialect}"/> -->
        <property name="showSql" value="false"/>               
        <property name="generateDdl" value="false"/>
        <!-- <property name="databasePlatform" value="org.hibernate.dialect.MySQL5Dialect"/> -->
        <!--  <property name="hibernate.connection.autocommit" value="false"/> -->
    </bean>
</property>
<property name="jpaPropertyMap">
    <map>
        <entry key="hibernate.connection.autocommit" value="false" />
    </map>
</property>

i wanted to know if this is the correct way to configure hibernate.dialect and what is the difference between them:

<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>

or

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

thank you!!

Upvotes: 2

Views: 6590

Answers (1)

user3020494
user3020494

Reputation: 732

I am not sure if other is valid syntax, but this works:

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

Update: I believe either one of them should work, prop key=hibernate.dilect is hibernate property and property name=databasePlatform is spring property.

you can wish to add one or more hibernate specific properties under < props>...

Upvotes: 2

Related Questions