Package org.jboss.tutorial.hibernate.bean

Examples of org.jboss.tutorial.hibernate.bean.CustomerRemote


{

   public static void main(String args[]) throws Exception
   {
      Context ctx = new InitialContext();
      CustomerRemote customerBean = (CustomerRemote) ctx.lookup("CustBean");
      // let's create customer#1
      long id = customerBean.createCustomer("Jai", "Pai");
      System.out.println("Jai Pai created with id = " + id);

      //let's create customer#2
      long custId2 = customerBean.createCustomer("Jaikiran", "Pai");
      System.out.println("Jaikiran Pai created with id = " + custId2);

      //one more customer
      long custId3 = customerBean.createCustomer("Jai", "NoLastName");
      System.out.println("Jai NoLastName created with id = " + custId3);

      // now let's find customer with some specific id
      System.out.println("Searching for customer with id = " + custId2);
      Customer customer = customerBean.getCustomer(custId2);
      System.out.println("Found customer " + customer.getFname() + " " + customer.getLname() + " with id = " + custId2);

     
      //let's use the other bean to search another customer
      CustomerRemote anotherCustomerBean = (CustomerRemote) ctx.lookup("AnotherCustBean");
      System.out.println("Searching for customer with id = " + custId3);
      Customer oneMoreCustomer = anotherCustomerBean.getCustomer(custId3);
      System.out.println("Found customer " + oneMoreCustomer.getFname() + " " + oneMoreCustomer.getLname() + " with id = " + custId3);

      // now let's find customers with first name=Jai
      System.out.println("Searching for customers with first name Jai");
      List<Customer> customers = customerBean.getCustomers("Jai");
      System.out.println("Found " + customers.size() + " customers with first name Jai");
     
      // let's use the other bean to find customers with name Jaikiran
      System.out.println("Searching for customers with first name Jaikiran");
      List<Customer> moreCustomers = anotherCustomerBean.getCustomers("Jaikiran");
      System.out.println("Found " + moreCustomers.size() + " customers with first name Jaikiran");
     

   }
View Full Code Here

TOP

Related Classes of org.jboss.tutorial.hibernate.bean.CustomerRemote

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.