• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

regarding code in MZ's notes?

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seeing this code from MZ's notes...my question is...
public abstract class CustomerBean implements javax.ejb.EntityBean {
...
public void addPhoneNumber(String number, byte type)
throws NamingException, CreateException {
InitialContext jndiEnc = new InitialContext();
PhoneHomeLocal phoneHome = (PhoneHomeLocal)
(jndiEnc.lookup("PhoneHomeLocal"));
PhoneLocal phone = phoneHome.create(number,type);
Collection phoneNumbers = this.getPhoneNumbers();
phoneNumbers.add(phone);
}
we did a JNDI look up for a home object and then used that to create a row with a number and type and the returned EJBObect is phone...then this.phoneNumbers() will return a collection of EJBObjects for the bean in CMR....now why did we do the phoneNumbers.add(phone), because we did a create (create(number,type)) the returned collection should already have this EJBObject. and i think there is no need for the add(phone) to really add a phone number.
can somebody explain this
thanks in advance
Pradeep
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

...because we did a create (create(number,type)) the returned collection should already have this EJBObject. and i think there is no need for the add(phone) to really add a phone number.


Create only inserts an new row into the table - an database entity. It only take care of persistent part, you still have to take care of the relationship part - defining the relationship for the newly created entity (phone), adding phone number the customer. Two aspects - persistent and relationship, don't mix up!
[ March 20, 2004: Message edited by: Alibabra Sanjie ]
 
Replace the word "snake" with "danger noodle" in all tiny ads.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic