aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Please Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Please Help " Watch "Please Help " New topic
Author

Please Help

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Can anyone please provide a simple example for Entity bean with Container managed relationship.
I tried google search but could not find any example.

Thanks
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Please provide one to many relationship example.
Thanks
Jonny Andersson
Ranch Hand

Joined: Sep 07, 2004
Posts: 87
The complicated things is not that much in the code but in how to successfully get it deployed. But okay, here is an example on a little bean with CMP for securities (stocks) which I have been able to deploy in the J2EE 1.3 RI app server from Sun.

The home interface:



The business component interface:



And the code for the bean, which is almost empty:



Well, we need a client also to be able to see it really happen when we have got the bean deployed. So here is a little client:



I have got this example to work in the J2EE 1.3 RI app server.

By the way, the named stocks is Swedish stocks
[ June 13, 2007: Message edited by: Jonny Andersson ]

Truly agile Java application developer with Extreme Programming and high quality craftsmanship
Jonny Andersson
Ranch Hand

Joined: Sep 07, 2004
Posts: 87
But was it not just a CMP bean you asked for for the first time? If you want some beans with CMR do I think you should start by look into a good book, for example HF EJB, or the J2EE 1.3 tutorial from Sun�s site which have some examples. You find their tutorial here http://java.sun.com/j2ee/tutorial/1_3-fcs/ (which can be found using google and the keywords j2ee 1.3 tutorial )
[ June 14, 2007: Message edited by: Jonny Andersson ]
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
Thanks Jonny for example
But the example which you have posted is for CMP example and i want example with CMR(1:m).
I am studying HFEJB but the example in book is not complete.
I tried Roster Example but i am not able to understand it.

Please help me.
Thanks
Jonny Andersson
Ranch Hand

Joined: Sep 07, 2004
Posts: 87
That is something that I also have been aware of about the HF EJB book, they have too few examples at least too few complete examples! So I read the most of J2EE 1.3 tutorial to get more examples. I don�t remember if I got the Roster example to work or not but I don�t have time to check it now because I have planed to be finished in about two weeks from now and still have much repetition left to do. Maybe did I get some trouble with the RI app server and skipped spend more time on trying to get it to work.

But if you understand CMP well do I suggest that you just read carefully about CMR as the major difference lies in different virtual accessors for CMR and that you have to use local interfaces for the related beans. I can understand you because I also like too really see things I read about and need to memorize working myself and do some hand on. But it takes a lot of time to try out every thing and at some time must the exam be finished. So I hope that reading the details for CMR should be enough.

Sometimes have I wondered why not a site like this one could have a section where someone could put a little working example (that is well commented and with good code!) with a client on every bean type and so on as so many is trying to learn the same thing. I could consider contribute to it myself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please Help