Java 类中的自反合成得到空值

Java 类中的自反合成得到空值,java,spring,dbunit,Java,Spring,Dbunit,我使用的是Spring3.1.1、DbUnit2.4.9、JUnit4.10和Hibernate4.1.4 我在构建一些测试时遇到了一个问题。在我的一个类中,自反合成的值为空: @Entity public class UserStep { private long id; private long version; private String code; private int stepOrder; private boolean activate;

我使用的是Spring3.1.1、DbUnit2.4.9、JUnit4.10和Hibernate4.1.4

我在构建一些测试时遇到了一个问题。在我的一个类中,自反合成的值为空:

@Entity
public class UserStep {

    private long id;
    private long version;
    private String code;
    private int stepOrder;
    private boolean activate;
    @OneToOne
    @JoinColumn(referencedColumnName="stepOrder")
    private UserStep nextStep;
//setter & getter...
}
指出问题的最简单测试:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/testApplicationContext.xml")
//AbstractTest contains methods which setup the db
public class CommonUserStepServiceTest extends AbstractTest {
    @Test
    public void goToPreviousUserStep_firstInstallation_NotFirstUserStep() {
        List<UserStep> findAll = userStepDAO.findAll();
        //I have 7 occurrences with correct label 
        //but null value for each UserStep.nextStep
    }
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(“/testApplicationContext.xml”)
//AbstractTest包含设置数据库的方法
公共类CommonUserStepServiceTest扩展了AbstractTest{
@试验
public void goToPreviousUserStep_firstInstallation_NotFirstUserStep(){
List findAll=userStepDAO.findAll();
//我有7次出现正确的标签
//但每个UserStep.nextStep的值都为空
}
用于加载引用的最简单xml文件:

<userStep id="7" activate="true" version="0" stepOrder="210" label="na" />
<userStep id="6" activate="true" version="0" stepOrder="60" label="end" />
<userStep id="5" activate="true" version="0" stepOrder="50" label="5" nextStep_stepOrder="60"/>
<userStep id="4" activate="true" version="0" stepOrder="40" label="4" nextStep_stepOrder="50"/>
<userStep id="3" activate="true" version="0" stepOrder="30" label="3" nextStep_stepOrder="40"/>
<userStep id="2" activate="true" version="0" stepOrder="20" label="2" nextStep_stepOrder="30"/>
<userStep id="1" activate="true" version="0" stepOrder="10" label="begin" nextStep_stepOrder="20"/>

将一些事件加载到我的测试工作中,过程中没有错误。 当我尝试访问nextStep属性时,我得到了null值,我不知道为什么。有人能帮我吗?
我还有其他使用UserStep table的测试,它们也可以工作(但我不尝试访问其中的nextStep属性)

问题来自于我在xml文件中的引用组织。解析器缺少nextStep\u stepOrder属性,因为它使用找到的第一个引用来确定所有列

解决方案是将
setColumnSensing(true)
添加到FlatXmlDataSetBuilder,以便动态添加所有列