-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: joined one-to-one table is not inserted
PostPosted: Tue Jan 28, 2014 11:07 pm 
Newbie

Joined: Tue Jan 28, 2014 10:29 pm
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.