I have a entity with an optional unidirectional one-to-one relationship.
@Entity @IdClass( value = MbiMsgpa.PK.class ) @Table( name = "mbi_msgpa" ) public class MbiMsgpa implements Serializable, Comparable<MbiMsgpa> ... /** Relation with MbiMsgpt. */ @OneToOne( cascade = { CascadeType.PERSIST, CascadeType.REMOVE }, fetch = FetchType.LAZY ) @Cascade( value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN ) @NotFound( action = NotFoundAction.IGNORE ) @PrimaryKeyJoinColumns( { @PrimaryKeyJoinColumn( name = "msghd_serial", referencedColumnName = "msghd_serial" ), @PrimaryKeyJoinColumn( name = "part_no", referencedColumnName = "part_no" ) } ) private MbiMsgpt mbiMsgpt; ... }
This worked using JBoss-4.2.4 using these Hibernate components hibernate-annotations: version="3.2.1.GA" hibernate-entitymanager: version="3.2.1.GA" hibernate: version="3.2.4.SP1_CP01-brew" but migrating to JBoss-6.0.0-SNAPSHOT with Hibernate Annotations 3.5.5-Final Hibernate 3.5.5-Final Hibernate Commons Annotations 3.2.0.Final Hibernate EntityManager 3.5.5-Final Hibernate Validator 3.1.0.GA Hibernate Validator 4.0.2.GA it fails.
I get this exception if there is no entry in MbiMsgpt: javax.persistence.EntityNotFoundException : Unable to find biz.mbisoftware.fn.ejb.entity.MbiMsgpt with id [MsghdSerial=7741;PartNo=1;] java.lang.reflect.InvocationTargetException : null biz.mbisoftware.common.exceptions.MbiException : java.lang.reflect.InvocationTargetException biz.mbisoftware.fn.ejb.entity.MbiMsgpt_$$_javassist_155(-1).getAdditionalData biz.mbisoftware.common.XmlHelper(291).methods2Xml biz.mbisoftware.common.XmlHelper(370).bean2Xml biz.mbisoftware.common.XmlHelper(301).methods2Xml biz.mbisoftware.common.XmlHelper(370).bean2Xml biz.mbisoftware.common.XmlHelper(123).collectionMethod2Xml biz.mbisoftware.common.XmlHelper(286).methods2Xml biz.mbisoftware.common.XmlHelper(368).bean2Xml biz.mbisoftware.fn.ejb.session.MessageDistributorType(73).buildTheXmlDocument biz.mbisoftware.fn.ejb.message.core.MessageDistributor(123).onMessage biz.mbisoftware.common.ParameterInterceptor(108).parameters: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21] at biz.mbisoftware.common.XmlHelper.methods2Xml(XmlHelper.java:291) [:] at biz.mbisoftware.common.XmlHelper.bean2Xml(XmlHelper.java:370) [:] at biz.mbisoftware.common.XmlHelper.methods2Xml(XmlHelper.java:301) [:] at biz.mbisoftware.common.XmlHelper.bean2Xml(XmlHelper.java:370) [:] at biz.mbisoftware.common.XmlHelper.collectionMethod2Xml(XmlHelper.java:123) [:] at biz.mbisoftware.common.XmlHelper.methods2Xml(XmlHelper.java:286) [:] at biz.mbisoftware.common.XmlHelper.bean2Xml(XmlHelper.java:368) [:] at biz.mbisoftware.fn.ejb.session.MessageDistributorType.buildTheXmlDocument(MessageDistributorType.java:73) [:] at biz.mbisoftware.fn.ejb.message.core.MessageDistributor.onMessage(MessageDistributor.java:123) [:] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21] at org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122) [jboss-aop.jar:2.2.1.Alpha3] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111) [jboss-aop.jar:2.2.1.Alpha3] at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72) [:1.0.8] at org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor$InvocationContext.proceed(InvocationContextInterceptor.java:138) [:1.0.8] at biz.mbisoftware.common.ParameterInterceptor.parameters(ParameterInterceptor.java:108) [:] at sun.reflect.GeneratedMethodAccessor459.invoke(Unknown Source) [:1.6.0_21] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21] at org.jboss.ejb3.interceptors.aop.EJB3InterceptorInterceptor.invoke(EJB3InterceptorInterceptor.java:83) [:1.0.8]
|