1 7 package org.jboss.tutorial.merge.client; 8 9 import org.jboss.tutorial.merge.bean.Customer; 10 import org.jboss.tutorial.merge.bean.CustomerDAO; 11 12 import javax.naming.InitialContext ; 13 14 import java.util.List ; 15 16 17 public class Client 18 { 19 public static void main(String [] args) throws Exception 20 { 21 InitialContext ctx = new InitialContext (); 22 CustomerDAO dao = (CustomerDAO) ctx.lookup(CustomerDAO.class.getName()); 23 24 System.out.println("Create Bill Burke and Monica Smith"); 25 dao.create("Bill", "Burke", "1 Boston Road", "Boston", "MA", "02115"); 26 int moId = dao.create("Monica", "Smith", "1 Boston Road", "Boston", "MA", "02115"); 27 28 System.out.println("Bill and Monica get married"); 29 Customer monica = dao.find(moId); 30 monica.setLast("Burke"); 31 dao.merge(monica); 32 33 System.out.println("Get all the Burkes"); 34 List burkes = dao.findByLastName("Burke"); 35 System.out.println("There are now " + burkes.size() + " Burkes"); 36 } 37 } 38 | Popular Tags |