English 中文(简体)
Hibernate: “Could not coordinated the database state with session” on flush
原标题:Hibernate: "Could not synchronize database state with session" on flush

当我试图在我下面的单位测试中 flu缩时,我会收到“不能使数据库状况与届会同步”。

谁能告诉问题是什么,因为我已经完全消失? 我只是试图在没有任何属性的情况下制定一条定义,而这种定义也不奏效。

成就

这是我的单位试验的幻灯。 摘要 翻译

@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();   
}

DAO方法仅指一种储蓄业务。 这是我的绘图档案。

<class name="abc.def.rules.RuleDefinition" table="REFDATA.CONFIG_RULE_DEFINITION">
    <id name="ruleId" column="RULE_ID">
        <generator class="increment"/>
    </id>
    <many-to-one name="attribute" cascade="none" class="abc.def.rules.ConfigAttribute" lazy="false" column="CONFIG_ATTR_ID"/>
    <many-to-one name="operator" cascade="none" class="abc.def.rules.Operator" lazy="false">
        <column name="OPRTR_VAL"/>
        <column name="OPRTR_VAL_DATA_TYP"/>
    </many-to-one>
    <many-to-one name="secondaryAttribute" cascade="none" class="abc.def.rules.ConfigAttribute" lazy="false" column="CONFIG_ATTR_ID_2" not-null="false"/>
    <property name="operand" column="OPRND_VAL" type="string"/>
    <property name="trueAction" column="TRUE_ACTN" type="string"/>
    <property name="falseAction" column="FALSE_ACTN" type="string"/>
    <property name="precedence" column="RULE_ORD_SEQ" type="int" not-null="true"/>
    <property name="currentState" column="RULE_STAT" type="string"/>
</class>

这是我春天组合档案的幻灯。

<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:abcdefhibernate-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>
最佳回答

我已设法解决了这一问题。 我的CONFIG_RULE_DEFINITION有一个制约因素,具体指出,时间段一栏不应失效,而且应当拖欠海关数据系统。 然而,海关数据表并不在HSQLDB I的原样中运行。 出于某种原因,没有任何这种错误预示着要通知我。 一旦我消除了这一限制,所有工作都得了!

问题回答

暂无回答




相关问题
handling exceptions IN Action Filters

Is there a better way to handle exceptions that occur inside an Action Filter itself in ASP .NET MVC? There re 2 ways I can think of at the moment. Using a try catch and setting the HTTP Status ...

既可捕获,又可举出例外。

我有一种办法,可以进入亚洲开发银行,因此,我国的亚行在多瑙河航道中的所有 st子都位于一个试捕区。 它正在追捕Kexception

Cross compiler exception handling - Can it be done safely?

I am doing some maintenance on a C++ windows dll library that is required to work with different VC++ compilers (as I don’t want to address different mangling schemes). I have already eliminated any ...

File Handling Issue

I am developing a tool in c#, at one instance I start writing into a xml file continuously using my tool,when i suddenly restart my machine the particular xml file gets corrupted, what is the reason ...

Watch a memory location/install data breakpoint from code?

We have a memory overwrite problem. At some point, during the course of our program, a memory location is being overwritten and causing our program to crash. the problem happens only in release mode. ...

Unit Test for Exceptions Message

Is there a simple (Attribute-driven) way to have the following test fail on the message of the exception. [TestMethod()] [ExpectedException(typeof(ArgumentException))] public void ExceptionTestTest() ...

热门标签