1 7 package org.jboss.tutorial.secondary.client; 8 9 import org.jboss.tutorial.secondary.bean.Customer; 10 import org.jboss.tutorial.secondary.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 22 InitialContext ctx = new InitialContext (); 23 CustomerDAO dao = (CustomerDAO) ctx.lookup(CustomerDAO.class.getName()); 24 25 System.out.println("Create Bill Burke and Monica Smith"); 26 dao.create("Bill", "Burke", "1 Boston Road", "Boston", "MA", "02115"); 27 int moId = dao.create("Monica", "Smith", "1 Boston Road", "Boston", "MA", "02115"); 28 29 System.out.println("Bill and Monica get married"); 30 Customer monica = dao.find(moId); 31 monica.setLast("Burke"); 32 dao.merge(monica); 33 34 System.out.println("Get all the Burkes"); 35 List burkes = dao.findByLastName("Burke"); 36 System.out.println("There are now " + burkes.size() + " Burkes"); 37 } 38 } 39 | Popular Tags |