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 ]
Effective Java Programming Language Guide: Think in terms of exported APIs because it tends to improve the quality of the software you write
Joined: Sep 07, 2004
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 ]
Joined: Feb 07, 2005
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
Joined: Sep 07, 2004
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.