0
私のアプリケーションでライブラリを更新して、新機能を追加しました。 Hibernate 3から4に移行しました。xmlを調整してImprovedNamingStrategy
が動作を停止しました。改良されたネーミング戦略Hibernate 4 not working
私はそれが下の構成で問題だと確信しています:アプリケーションがでも実際そのdocumentHistory
と呼ばれる新しいものを作成されたデータベースにdocument_historyという名前の列がありますが
<?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:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<!-- How to include more then one base package -->
<context:annotation-config/>
<context:component-scan base-package="com.lotjm"/>
<context:property-placeholder location="classpath:./properties/database.properties"/>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="com.lotjm"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true"/>
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider"></bean>
</property>
</bean>
<jpa:repositories base-package="com.lotjm.repository"
factory-class="org.springframework.data.envers.repository.support.EnversRevisionRepositoryFactoryBean"/>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
</props>
</property>
<property name="annotatedClasses">
<list>
<value>com.xx.domain.User</value>
<value>com.x.domain.Application</value>
<value>com.xx.domain.Project</value>
<value>com.xxx.domain.Document</value>
<value>com.xxx.domain.AbstractAuditingEntity</value>
</list>
</property>
<property name="namingStrategy">
<bean class="org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy"/>
</property>
</bean>
<bean id="auditingProvider" class="com.lotjm.config.audit.UsernameAuditorAware"/>
<bean id="dateTimeService" class="com.lotjm.config.audit.CurrentTimeDateTimeService"/>
<bean id="dateTimeProvider" class="com.lotjm.config.audit.AuditingDateTimeProvider">
<constructor-arg index="0" ref="dateTimeService"/>
</bean>
<jpa:auditing auditor-aware-ref="auditingProvider" set-dates="true" date-time-provider-ref="dateTimeProvider"/>
</beans>
それは新しい列を作成して間違っています。
<prop key="hibernate.hbm2ddl.auto">validate</prop>