Hi there,
I am facing a problem with unit testing of my daoImpl class. I have a one-to-one relationship bwteen table A and B with a joined table A_B
Code:
]<class name="A">
<id name="id" column="aId">
<generator class="native"/>
</id>
<property name="ap" column="a_property" />
<join table="A_B"
optional="true">
<key column="aId"
unique="true"/>
<many-to-one name="b"
column="bId"
not-null="true"
unique="true"/>
</join>
</class>
<class name="b">
<id name="id" column="bId">
<generator class="native"/>
</id>
</class>
The tested daoImpl is doing:
Code:
A a = session.findAById(1);
a.setAP("Y");
a.setB(session.findBById(1) );
session.update(A);
When running application itself, the log shows below and I can see a new row inserted in joined table A_B
Code:
insert A
update A
insert A_B
update A_B
But when running unit test, the log only shows update statement, so the joined table A_B is not inserted.
Code:
update A
update A_B
I wonder in what situation this could happen? Why same code, unit test Hibernate Session does not do insert? Thanks!