Why to use jpadialect in JpaTransactionManager

半世苍凉 提交于 2019-12-22 11:38:15

问题


I am learning spring 3.0 from Spring in Action.

There it talks about importance of having jpadialect in JpaTranactionManager

<bean id="transactionManager"
              class="org.springframework.orm.jpa.JpaTransactionManager">
          <property name="entityManagerFactory" ref="entityManagerFactory" />
          <property name="jpaDialect" ref="jpaDialect" />
        </bean>
<bean id="jpaDialect"
        class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />

However the dialect is already present in declaration of entityManagerFactory via jpaVendorAdaptor.

<bean id="entityManagerFactory" class= "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>
<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
  <property name="database" value="HSQL" />
  <property name="showSql" value="true"/>
  <property name="generateDdl" value="false"/>
  <property name="databasePlatform"
            value="org.hibernate.dialect.HSQLDialect" />
</bean>  
 <bean id="dataSource" class="org.springframework.jdbc.datasource. DriverManagerDataSource">
   <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
   <property name="url" value="jdbc:hsqldb:hsql://localhost/spitter/spitter" />
   <property name="username" value="sa" />
   <property name="password" value="" />
 </bean>

Is the use of dialect in JpaTranactionManager redundant?


回答1:


The use of jpaDialect in JpaTransactionManager is no redundant to jpaVendorAdapter config. Their config have different purpose.

You can refer this post with good explanation.



来源:https://stackoverflow.com/questions/25008082/why-to-use-jpadialect-in-jpatransactionmanager

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!