@Override @Transactional(noRollbackFor = {Throwable.class}) public void saveTwo(User o1, User o2) { userDAO.save(o1); info("save user name: " + o1.getName()); userDAO.save(o2); }
@RequestMapping("/save") public String save( Model model, @RequestParam(required = false) String name, @RequestParam(required = false) String sex, @RequestParam(required = false) String ageStr) { int age = 0; try { age = Integer.parseInt(ageStr); } catch (NumberFormatException e) { } ; User user = new User(); user.setName(name); user.setSex(sex); user.setAge(age); user.setBorn(new Date()); boolean status = userDAO.save(user); model.addAttribute("status", status); return "save"; }