コード例 #1
0
 @RequestMapping(value = "/customerDelete/{id}")
 @Transactional
 public String delete(@PathVariable Long id) {
   Customer customer = customerRepository.findOne(id);
   if (customer != null) {
     customerRepository.delete(customer);
   }
   return "redirect:/customer";
 }
コード例 #2
0
 @RequestMapping(value = "/customerClear/{id}")
 @Transactional
 public String clear(@PathVariable Long id) {
   Customer customer = customerRepository.findOne(id);
   if (customer != null) {
     customer.setSurveyInfo(new SurveyInfo());
     customerRepository.save(customer);
   }
   return "redirect:/customer/" + id;
 }
コード例 #3
0
 @RequestMapping(value = "/customer", method = RequestMethod.GET)
 public String list(Model model) {
   String dbInfo = "?";
   try {
     dbInfo =
         (String)
             JdbcUtils.extractDatabaseMetaData(
                 dataSource,
                 new DatabaseMetaDataCallback() {
                   public Object processMetaData(DatabaseMetaData dbmd)
                       throws SQLException, MetaDataAccessException {
                     String info =
                         dbmd.getDatabaseProductName() + " " + dbmd.getDatabaseProductVersion();
                     return info;
                   }
                 });
   } catch (MetaDataAccessException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   List<Customer> customers = customerRepository.findAll();
   model.addAttribute("dbinfo", dbInfo);
   model.addAttribute(customers);
   return "customer/list";
 }