• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Working example of persistent relationships in Remote-Local entity

 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm having problem getting a Remote Entity Bean (Customer) to work with a Local Entity Bean (Address) through a conatiner-managed-relationship on a J2EE-RI.
Does anyone has any link to a simple working example or a tutorial?
The tutorial by Sun is not complete, or at least for my standard as I'm just beginning to try CMR out.
I'd apprecitate any reference or link.
Thanks.

Han Ming
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, you should notice that cmr relationships from ejb 2.0 specifications are only allowed between entity beans with local interfaces and declared in the same ejb-jar.xml deployment descriptor.

Originally posted by HanMing Low:

I'm having problem getting a Remote Entity Bean (Customer) to work with a Local Entity Bean (Address) through a conatiner-managed-relationship on a J2EE-RI.

 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marcos,
Thanks so much for your reply.
Is this right??
I must say I'm really not aware of this limitation. However, I'm refering to "Enterprise JavaBeans" by Richard Monson-Haefel Chapter 6 page 171 to 182 in particular refering to 175, 176 where an example of Remote Entity Bean is created.
However, I'm really thank you for the advice.
I'll read up the spec on this area and try out an example of session->local entity->local entity.
Will keep update in this thread.
Thanks.

Han Ming
 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Marcos is right. It is illegal to reference a local interface or local home type in a remote interface. And It is illegal to define a method that accepts or returns local interface reference in a remote interface.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JiaPei,
Thanks for your reply.
I'd just like to clarify one small doubt again.
I understand that
Remote client -> Entity A with Local interface
is not allowed.
Does it means that
Remote client -> Entity B with Remote interface -> Entity A with Local interface.
is not allowed even Entity B and A are residing in the same EJB Container?
I thought that so long the bean are run with the same VM, you should be able to access it local interface.
Please correct me if I'm wrong.
Thanks.

Han Ming
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Entity B and Entity A reside and are deployed in the same JVM; therefore, they can reference each other through their local interface.
Remote client cannot reference Entity B or Entity A through their local interface.
Remote client must reference Entity B and Entity A through remote interface.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JiaPei,
Thanks for your clarification.
I understand what you've mentioned.
So, what I'm trying to do is to use Client to reference Entity A through Entity A's remote reference and Entity A in turn reference Entity B through Entity B local reference.
Both Entity A and B are CMP and I'm trying to get their relationship managed by the container as well.
But the good news for me is that I have managed to get it working.
The example in the "EJB" book is corrected, just that the table created does not match the code of the AddressBean causing the RollbackException.
So, what I finally did was to test the bean separately and get it working by using a SessionBean to invoke them individually.
After I corrected the AddressBean problem, I managed to get the CMR working too.
Just for anyone who is beginning in CMR.
If you need a example on CMR for J2EE-RI, you can e-mail to me for a VERY simple example.
But at least it works for me to get my understanding right.
And thanks for the replies to my post.
Cheers.

Han Ming
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would you e-mail me the simple CMR example you did? My e-mail address is
[email protected]
Thank you.
 
HanMing Low
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Sure, but let me tidy up the super ugly code before sending over to you.

Give me a day or two, OK?
Cheers.

Han Ming
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic