I am confused. I have just moved code from JBoss 4.2.2 to JBoss 7.1.1. I have a parent-child relationship mapped like this:
<class name="UserMedium" ...> . . . <set name="mailDelays" inverse="true" cascade="save-update" order-by="dateReported desc" lazy="false"> <key column="usermediumid" not-null="true"/> <one-to-many class="MailDelay"/> </set> . . . </class>
<class name="MailDelay" ...> . . . <many-to-one name="userMedium" column="usermediumid" not-null="true" lazy="false" fetch="join"/> . . . </class>
I have a Session Bean whose job it is to decide if the relationship should be persisted. Given a MailDelay with a valid UserMedium reference, it may decide to add the MailDelay to the UserMedium's collection of mail delays, or it may not. If it does, it does this (from within an active Persistence Context) (assume that hbmSession is the EntityManager's delegate):
hbmSession.update(mailDelay.getUserMedium()); mailDelay.getUserMedium().addMailDelay(mailDelay);
and the UserMedium implementation of addMailDelay(MailDelay mailDelay) looks like this:
public void addMailDelay(MailDelay mailDelay) { getMailDelays().add(mailDelay); mailDelay.setUserMedium(this); } When the transaction commits I see this in the logs:
17:32:48,634 INFO [stdout] (ajp--127.0.0.1-8009-1) Hibernate: update users_media set username=?, mediumid=?, ...... where usermediumid=?
There is no insert into the mail_delays table. This is different from the behavior in 4.2.2. In 4.2.2, it worked as expected, i.e., the new mail delay was added to the mail_delays table.
Can anyone provide some insight?
I'd much appreciate it.
Richard
|