Package org.jboss.tutorial.hibernate

Examples of org.jboss.tutorial.hibernate.Customer


   @PersistenceContext
   private Session session;

   public long createCustomer(String fname, String lname)
   {
      Customer customer = new Customer();
      customer.setFname(fname);
      customer.setLname(lname);
      this.session.persist(customer);
      logger.info("Created new customer with name = " + fname + " " + lname + " with id = " + customer.getId());
      return customer.getId();
   }
View Full Code Here


      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");
View Full Code Here

   @PersistenceContext
   private EntityManager em;

   public long createCustomer(String fname, String lname)
   {
      Customer customer = new Customer();
      customer.setFname(fname);
      customer.setLname(lname);
      this.em.persist(customer);
      logger.info("Created new customer with name = " + fname + " " + lname + " with id = " + customer.getId());
      return customer.getId();

   }
View Full Code Here

TOP

Related Classes of org.jboss.tutorial.hibernate.Customer

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.