Well, I solved it but not how you suggested (although, thanks for resonding) and I'm more confused now about relationships than when I started. I just changed my target-multiple="no" tag to target-multiple="yes". Now, the multiplicity for my PfinetUser changes from 'One' to 'Many' which, as I said confuses me because 1) everything I've read for 1:1 relationships has 'One' for the multiplicity element in both ejb-relationship-role elements of the ejb-relation in ejb-jar.xml and 2) it works not as I expected but as I want.
In regards to your post, I looked over the xPetstore stuff quite a lot but in my understanding of relationships, your example you post is a bidirectional relationship because of the accessibility of the Child from the Parent and the Parent from the Child. I only need and want accessibility of the Child from the Parent. And it's not really a Parent/Child relationship because that assumes the Child can't exist without the Parent. My Child (Department) will exist without the Parent (PfinetUser) and will have relationships with other entities as well. But, as I said, I thought I had a handle on relationships until doing something I think is wrong turned out to solve my problem. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Adam Sent: Wednesday, February 19, 2003 3:00 PM To: [EMAIL PROTECTED] Subject: Re: [Xdoclet-user] JBoss CMR problem Jeff: I was dealing with this very problem last night of 1:1 uni relationship between parent and child. All I can say is "bless the xPetstore demo!" for it showed me the way. Here's what I learned in regard to properly setting up the relationship. This example uses JBoss. I used the Product:Item relationship from the xPetstore to figure this out. For a Parent that has a child, where the tables should end up looking like: parent: ------- parentID : integer parentInfo : varchar child: ------- childID : integer childInfo : varchar parentId : integer In the ParentEJB: /** * returns the child from a Parent object * * @return a Child object * @ejb.interface-methid * @ejb.relation * name="parent-child" * role-name="parent-has-child" */ public abstract ChildLocal getChild(); In the ChildEJB: /** * Returns the Parent * * @ejb.interface-method * * @ejb.relation * name="parent-child" * role-name="child-belongs_to-parent * cascade-delete="yes" * * @jboss.relation * related-pk-field="parentId" * fk-column="parent_id_fk" */ public abstract ParentLocal getParent(); Note: parentId relates to the Parent.getParentId() method the column "parent_id_fk" will be the column created in the Child table. I hope this helps solve your problem. -- adam ----- Original Message ----- From: "Jeff Markham" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, February 18, 2003 7:13 PM Subject: [Xdoclet-user] JBoss CMR problem (I'm an XDoclet newbie) I have a 1-to-1 unidirectional relationship. It is User ---> Department. All works seemingly well until ejbPostCreate where I'm setting the Department CMR field. I've posted my problem on the JBoss CMP forum a couple times but no response. Others with the same problem seem to also using XDoclet so I thought I'd see if there's any XDoclet users who've had this problem and managed to have it solved. Any guidance would be greatly appreciated. Thank you. Code snippets: PfinetUser ------------------------------------ * @ejb.bean * type="CMP" * cmp-version="2.x" * name="PfinetUser" * jndi-name="ejb/pfi/security/PfinetUser" * view-type="both" * schema="PfinetUser" . . . /** * @param department the new CMR value * * @ejb.interface-method */ public abstract void setDepartment(Department department); /** * This is a uni-directional one-to-one relationship CMR method * * @return the related com.pfi.sys.DepartmentLocal. * * @ejb.relation * name="departments-pfinet_users" * role-name="pfinet_user-has-department" * target-ejb="Department" * target-role-name="department-has-pfinet_user" * target-multiple="no" * @ejb.interface-method * @jboss.relation-mapping style="foreign-key" * @jboss.relation * fk-constraint="true" * fk-column="department" * related-pk-field="id" */ public abstract Department getDepartment(); . . . /** * @ejb.create-method */ public PfinetUserPK ejbCreate(PfinetUserValue data, Department department) throws CreateException { setUserId(data.getUserId()); setPfinetUserValue(data); return null; } public void ejbPostCreate(PfinetUserValue data, Department department) throws CreateException { setDepartment(department); } The exception ------------------------------------ javax.ejb.EJBException: Data contains multiple values, but this cmr field is single valued at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBr idge.java:943) at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBr idge.java:931) at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getRelatedId(JDBCCM RFieldBridge.java:833) at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationIn terceptor.java:105) at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchron izationInterceptor.java:303) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach edConnectionInterceptor.java:186) at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInt erceptor.java:65) at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterce ptor.java:168) at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.jav a:107) at org.jboss.ejb.plugins.EntityCreationInterceptor.invoke(EntityCreationInterce ptor.java:69) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor .java:108) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT. java:267) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:101) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:13 0) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinde rInterceptor.java:154) at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:481) at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.invokeGetRelatedId( JDBCCMRFieldBridge.java:736) at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.createRelationLinks (JDBCCMRFieldBridge.java:661) at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setInstanceValue(JD BCCMRFieldBridge.java:636) at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.setValue(JDBCCMRFie ldBridge.java:567) at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(Entity BridgeInvocationHandler.java:126) at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59) at com.pfi.security.PfinetUserCMP$Proxy.setDepartment(<generated>) at com.pfi.security.PfinetUserEJB.ejbPostCreate(PfinetUserEJB.java:383) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.ejb.plugins.CMPPersistenceManager.postCreateEntity(CMPPersistenceM anager.java:288) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.postCreateE ntity(CachedConnectionInterceptor.java:278) at org.jboss.ejb.EntityContainer.postCreateLocalHome(EntityContainer.java:583) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.ja va:1085) at org.jboss.ejb.plugins.cmp.jdbc.JDBCRelationInterceptor.invoke(JDBCRelationIn terceptor.java:95) at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchron izationInterceptor.java:303) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach edConnectionInterceptor.java:186) at org.jboss.ejb.plugins.EntityReentranceInterceptor.invoke(EntityReentranceInt erceptor.java:91) at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterce ptor.java:168) at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.jav a:107) at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInt erceptor.java:59) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor .java:112) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT. java:237) at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:71) at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.jav a:105) at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryF inderInterceptor.java:125) at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:475) at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyF actory.java:271) at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110) at $Proxy176.create(Unknown Source) at com.pfi.security.SecurityFacadeEJB.addUser(SecurityFacadeEJB.java:102) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 ) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl .java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(Stateles sSessionContainer.java:606) at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(Cach edConnectionInterceptor.java:186) at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSe ssionInstanceInterceptor.java:77) at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor .java:108) at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT. java:237) at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:101) at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:13 0) at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:204) at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinde rInterceptor.java:154) at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.jav a:303) at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFacto ry.java:351) at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionPro xy.java:81) at $Proxy196.addUser(Unknown Source) at com.pfi.security.SecurityServlet.doAdd(SecurityServlet.java:150) at com.pfi.security.SecurityServlet.service(SecurityServlet.java:298) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:550) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2 46) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.jboss.web.catalina.session.ClusteredSessionValve.invoke(ClusteredSession Valve.java:78) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.ajp.tomcat4.Ajp13Processor.process(Ajp13Processor.java:458) at org.apache.ajp.tomcat4.Ajp13Processor.run(Ajp13Processor.java:551) at java.lang.Thread.run(Thread.java:536) ------------------------------------------------------- This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user ------------------------------------------------------- This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user ------------------------------------------------------- This SF.net email is sponsored by: SlickEdit Inc. Develop an edge. The most comprehensive and flexible code editor you can use. Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial. www.slickedit.com/sourceforge _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
