1 package org.objectweb.rentacar.persistance.dao; 2 3 import org.objectweb.rentacar.persistance.bo.Address; 4 import org.objectweb.rentacar.persistance.bo.Contact; 5 6 11 public class ContactDAO extends GenericDAO { 12 13 private static ContactDAO theInstance; 14 15 private ContactDAO(){ 16 17 } 18 19 public static synchronized ContactDAO getInstance() { 20 if (null == theInstance) { 21 theInstance = new ContactDAO(); 22 } 23 return theInstance; 24 } 25 26 32 public void updateContactAddress(String contactId, Address newAddress) throws DAOException { 33 Contact contact = null; 34 35 contact = (Contact)retrieveById(Contact.class, contactId); 36 37 Address oldAddress = contact.getAddress(); 38 39 contact.setAddress(newAddress); 40 41 update(contact); 42 43 delete(oldAddress); 44 45 } 46 47 } 48 | Popular Tags |