以下のユニットテストでフラッシュを試みると、 "データベース状態をセッションと同期できませんでした"というメッセージが表示されます。Hibernate: "データベース状態をセッションと同期できませんでした"
私は完全に失われているので、問題が何であるかアドバイスできますか?私は、その属性を設定せずにRuleDefinitionを作成しようとしましたが、どちらも機能しません。
おかげ
これはDAOのメソッドは、単に保存操作を呼び出すAbstractTransactionalDataSourceSpringContextTests
@Test
public void testCreateRule() {
RuleDefinition ruleReturned = (RuleDefinition) hibernateRuleDefinitionDao.findRule(1);
RuleDefinition newRule = new RuleDefinition();
newRule.setCurrentState("ACTIVE");
newRule.setAttribute(ruleReturned.getSecondaryAttribute());
newRule.setSecondaryAttribute(ruleReturned.getAttribute());
newRule.setOperator(ruleReturned.getOperator());
newRule.setPrecedence(4);
hibernateRuleDefinitionDao.createRule(newRule);
// Exception is thrown after the flush
hibernateTemplate.flush();
}
を拡張し、私のユニットテストの抜粋です。これは、これは私がこの自分自身を解決するために管理してきた私のSpring構成ファイル
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:mem:testdb" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocations">
<list>
<value>classpath:abc\def\hibernate-reference.cfg.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.HSQLDialect
</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.NoCacheProvider
</prop>
<prop key="hibernate.cache.use_second_level_cache">
false
</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
</props>
</property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
** ConfigAttribute **または** Operator **から** RuleDefinition **への逆マッピングがありますか? – ManuPK