for(Customer customer : myList) { if(customer!=null && "Doe".equals(customer.getName())) customer.setEmail("abc@xyz.com"); }
@Path("/services") public class MaisonService { @GET @Path("/test") @Produces(MediaType.APPLICATION_JSON) public Customer getSampleCustomer() { Customer sampleCustomer = new Customer(); sampleCustomer.setFullName("Trinh Toan Trung"); sampleCustomer.setEmail("trinhtoantrung@gmail.com"); return sampleCustomer; } ..
@GET @Produces(MediaType.APPLICATION_XML) @Path("/getCustomer") public Customer getCustomer() { Customer c = new Customer(); c.setName("Fred"); c.setEmail("fred@email.com"); c.setId(12345); return c; }
@RequestMapping(value="sendData" ,method = RequestMethod.POST) public String add(HttpServletRequest request, ModelMap model) { String firstName = request.getParameter("firstName"); String lastName = request.getParameter("lastName"); String email = request.getParameter("email"); System.out.println(email); System.out.println(firstName); System.out.println(lastName); Customer c = new Customer(); c.setFirstName(firstName); c.setLastName(lastName); c.setEmail(email); c.setDate(new Date()); PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.makePersistent(c); } finally { pm.close(); } return "successpage"; }
@RequestMapping(value = "/list", method = RequestMethod.POST) public ModelAndView add(HttpServletRequest request, ModelMap model) { String email = request.getParameter("email"); String password = request.getParameter("password"); Customer c = new Customer(); c.setEmail(email); c.setPassword(password); c.setDate(new Date()); PersistenceManager pm = PMF.get().getPersistenceManager(); try { pm.makePersistent(c); } finally { pm.close(); } return new ModelAndView("redirect:command"); }
helper = new HibernateHelper(); Customer custObject; if (customer.getId() == 0) { custObject = new Customer(); custObject.setCreatetimestamp(new Timestamp(System.currentTimeMillis())); } else { custObject = (Customer) helper.getSession().load(Customer.class, customer.getId()); } custObject.setName(customer.getName()); custObject.setAddress(customer.getAddress()); custObject.setBillToAddress(customer.getBillToAddress()); custObject.setBillToPerson(customer.getBillToPerson()); custObject.setUpdatetimestamp(new Timestamp(System.currentTimeMillis())); custObject.setEmail(customer.getEmail()); custObject.setDeleted(false); Currency curr = (Currency) helper.getSession().load(Currency.class, x); custObject.setCurrencyId(curr); custId = (Long) helper.getSession().save(custObject); helper.commit();
@SpringBootApplication public class SpringHibernateDemoApplication { public static void main(String[] args) { SpringApplication.run(SpringHibernateDemoApplication.class, args); } @Bean public CustomerDao customerDao() { return new CustomerDao(); } @Bean public CommandLineRunner runner(CustomerDao dao) { return new CommandLineRunner() { @Override public void run(String... args) throws Exception { Customer customer = new Customer(); customer.setFistName("amar"); customer.setLastName("dev"); customer.setEmail("amar@gmail.com"); dao.saveCustomer(customer); } }; } }
@SpringBootApplication public class SpringHibernateDemoApplication { public static void main(String[] args) { SpringApplication.run(SpringHibernateDemoApplication.class, args); } @Bean public CommandLineRunner runner(CustomerDao dao) { return new CommandLineRunner() { @Override public void run(String... args) throws Exception { Customer customer = new Customer(); customer.setFistName("amar"); customer.setLastName("dev"); customer.setEmail("amar@gmail.com"); dao.save(customer); } }; } }
while (rs.next()) { Customer customer = new Customer(); customer.setId(rs.getInt("id")); customer.setName(rs.getString("name")); customer.setAddress(rs.getString("address")); customer.setPhone(rs.getString("phone")); customer.setEmail(rs.getString("email")); customer.setBountPoints(rs.getInt("bonuspoint")); customer.setTotalsale(rs.getInt("totalsale")); customers.add(customer); }
private Controller controller = new Controller(); @Override public void actionPerformed(ActionEvent e) { Customer c = new Customer(); c.setOrgNumber(textFieldOrgNr.getText()); c.setCompanyName(textFieldComanyName.getText()); c.setBillingAdress(textFieldBillingAdress.getText()); c.setCompanyContact(textFieldCompanyContact.getText()); c.setEmail(textFieldEmail.getText()); c.setAgreement(textFieldAgreement.getText()); c.setPhoneNumber(textFieldPhoneNumber.getText()); controller.addCustomer(c); } });