adding phone and address records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oll3i
    Contributor
    • Mar 2007
    • 679

    adding phone and address records

    I add contact records
    Code:
    try {
        InitialContext ic = new InitialContext();
        Object objContactBean = ic.lookup("java:comp/env/ejb/ContactRef");
        LocalContactHome contactHome = (LocalContactHome) objContactBean;
    
        contactHome.create("01", "Andrzej", "Miążek","andrzej_miazek@op.pl");
        contactHome.create("02", "Michał", "Kacper","michal_kacper@op.pl");
        contactHome.create("03", "Aleksandra", "Owczarek","aleksa1981@wp.pl"); 
        contactHome.create("04", "Krzysztof", "Żak","zaczek@poczta.onet.pl");
        contactHome.create("05", "Oskar", "Paprocki","oskarek1984@qmail.com");
    
    } catch(Exception e) {
        e.printStackTrace();
        out.println("Create Contacts Failed : " + e.toString()); 
    }
    then i want to add phones and addresses records
    do i use only the "create" method defined in LocalAddressHom e and in LocalPhoneHome

    the relationship between ContactBean and PhoneBean is one to many the same with addresses the referencing field from ContactBean to PhoneBean is "phones" a collection and from ContactBean to AddressBean is "addresses" a collection
    Does the contactID go to the database when i invoke "create" method of LocalAddressHom e or LocalPhoneHome


    my interfaces
    LocalAddressHom e:
    Code:
    public interface LocalAddressHome extends EJBLocalHome {
        public LocalAddress create (
                String contactID,
                String addressID,
                String street, 
                String city, 
                String zip, 
                String country)
            throws CreateException;
    
        public LocalAddress findByPrimaryKey(String addressID)
            throws FinderException;
    }
    LocalPhoneHome:
    Code:
    public interface LocalPhoneHome  extends EJBLocalHome {
    	    public LocalPhone create (
    	    		String contactID,
    	    		String phoneID,
    	            String phone)
    	        throws CreateException;
    	    public Collection findAllPhones ()
    	        throws FinderException;
    	    public LocalPhone findByPrimaryKey(String phoneID)
    	        throws FinderException;
    	    public Collection findByContactID(String contactID) 
    	    throws FinderException;
    
    	}
    Last edited by Nepomuk; Dec 7 '08, 09:33 PM. Reason: Added [CODE] tags
  • oll3i
    Contributor
    • Mar 2007
    • 679

    #2
    hihi i'm addicted ... another addiction on my list :) but it's a good addiction

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #3
      Sorry if this seems weird, but what is your actual question here?

      Greetings,
      Nepomuk

      Comment

      Working...