<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
optional OneToOne relation
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/lafr">Frank Langelage</a> in <i>EJB 3.0</i> - <a href="http://community.jboss.org/message/562556#562556">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>I have a entity with an optional unidirectional one-to-one relationship.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>@Entity<br/>@IdClass( value = MbiMsgpa.PK.class )<br/>@Table( name = "mbi_msgpa" )<br/>public class MbiMsgpa implements Serializable, Comparable<MbiMsgpa><br/>...</p><p>/** Relation with MbiMsgpt. */<br/>    @OneToOne( cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, fetch = FetchType.LAZY )<br/>    @Cascade( value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN )<br/>    @NotFound( action = NotFoundAction.IGNORE )<br/>    @PrimaryKeyJoinColumns( {<br/>        @PrimaryKeyJoinColumn( name = "msghd_serial", referencedColumnName = "msghd_serial" ),<br/>        @PrimaryKeyJoinColumn( name = "part_no", referencedColumnName = "part_no" )<br/>    } )<br/>    private MbiMsgpt mbiMsgpt;</p><p>...</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This worked using JBoss-4.2.4, but migrating to JBoss-6.0.0.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>But using JBoss6 I get an exception like this:</p><p>2010-09-18 22:00:15,055 ERROR [biz.mbisoftware.common.XmlHelper] (Thread-2 (group:HornetQ-client-global-threads-21860387))<br/>    javax.persistence.EntityNotFoundException : Unable to find biz.mbisoftware.fn.ejb.entity.MbiMsgpt with id [MsghdSerial=7741;PartNo=1;]<br/>    java.lang.reflect.InvocationTargetException : null<br/>    biz.mbisoftware.common.exceptions.MbiException : java.lang.reflect.InvocationTargetException<br/>    biz.mbisoftware.fn.ejb.entity.MbiMsgpt_$$_javassist_155(-1).getAdditionalData<br/>    biz.mbisoftware.common.XmlHelper(291).methods2Xml<br/>    biz.mbisoftware.common.XmlHelper(370).bean2Xml<br/>    biz.mbisoftware.common.XmlHelper(301).methods2Xml<br/>    biz.mbisoftware.common.XmlHelper(370).bean2Xml<br/>    biz.mbisoftware.common.XmlHelper(123).collectionMethod2Xml<br/>    biz.mbisoftware.common.XmlHelper(286).methods2Xml<br/>    biz.mbisoftware.common.XmlHelper(368).bean2Xml<br/>    biz.mbisoftware.fn.ejb.session.MessageDistributorType(73).buildTheXmlDocument<br/>    biz.mbisoftware.fn.ejb.message.core.MessageDistributor(123).onMessage<br/>    biz.mbisoftware.common.ParameterInterceptor(108).parameters: java.lang.reflect.InvocationTargetException<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]<br/>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]<br/>    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]<br/>    at biz.mbisoftware.common.XmlHelper.methods2Xml(XmlHelper.java:291) [:]<br/>    at biz.mbisoftware.common.XmlHelper.bean2Xml(XmlHelper.java:370) [:]<br/>    at biz.mbisoftware.common.XmlHelper.methods2Xml(XmlHelper.java:301) [:]<br/>    at biz.mbisoftware.common.XmlHelper.bean2Xml(XmlHelper.java:370) [:]<br/>    at biz.mbisoftware.common.XmlHelper.collectionMethod2Xml(XmlHelper.java:123) [:]<br/>    at biz.mbisoftware.common.XmlHelper.methods2Xml(XmlHelper.java:286) [:]<br/>    at biz.mbisoftware.common.XmlHelper.bean2Xml(XmlHelper.java:368) [:]<br/>    at biz.mbisoftware.fn.ejb.session.MessageDistributorType.buildTheXmlDocument(MessageDistributorType.java:73) [:]<br/>    at biz.mbisoftware.fn.ejb.message.core.MessageDistributor.onMessage(MessageDistributor.java:123) [:]<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]<br/>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]<br/>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]<br/>    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122) [jboss-aop.jar:2.2.1.Alpha3]<br/>    at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) [jboss-aop.jar:2.2.1.Alpha3]<br/>    at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72) [:1.0.8]<br/>    at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:138) [:1.0.8]<br/>    at biz.mbisoftware.common.ParameterInterceptor.parameters(ParameterInterceptor.java:108) [:]<br/>    at sun.reflect.GeneratedMethodAccessor459.invoke(Unknown Source) [:1.6.0_21]<br/>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]<br/>    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]<br/>    at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:83) [:1.0.8]</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/562556#562556">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in EJB 3.0 at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>