Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: ??? Large Objects may not be used in auto-commit mode

  1. #11
    Join Date
    Mar 2011
    Posts
    18

    Talking Solved

    Finally, I got a nice working solution after having a more detailed look on the stack trace. Saves everything in a transaction:
    Code:
    	@Autowired
    	private ConversionService conversionService;
    	@Autowired  
    	private Validator validator;
    
    	...
    
    	@RequestMapping(method = RequestMethod.POST)
    	@Transactional
    	public String edit(@PathVariable("type") final String type,
    			Model model, HttpServletRequest req)
    			throws Exception {
    		// retrieve command object
    		Object entity = getCommand(type, req);
    		// validate and bind request data, manually
    		ServletRequestDataBinder binder = new ServletRequestDataBinder(entity);
    		binder.setConversionService(conversionService);
    		binder.setValidator(validator);
    		binder.bind(req);
    		binder.validate();
    		BindingResult result = binder.getBindingResult();
    		if (model!=null)
    			// publish BindingResult in model
    			model.addAttribute(BindingResult.MODEL_KEY_PREFIX + name, result);
    		// do save entity or display error
    		Long id = getId(entity);
    		if (result.hasErrors()) { // validation failed
    			prepareModel(model, type, type + (id==null ? ".create" : ".update"), entity);
    			return getViewName(type, "edit");
    		}
    		// save entity
    		if (id==null)
    			facade.create(entity);
    		else
    			facade.edit(entity);
    		return "redirect:/system/" + type + "/"
    				+ encodeUrlPathSegment(getId(entity).toString(), req)
    				+ "/edit";
    	}
    
    	...
    Last edited by MaxMan; May 10th, 2011 at 05:10 PM.

Similar Threads

  1. Replies: 1
    Last Post: Jun 24th, 2007, 10:58 AM
  2. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  3. Replies: 3
    Last Post: Aug 4th, 2005, 01:34 PM
  4. Spring/Hibernate Delete/Update Problem
    By Noname in forum Data
    Replies: 4
    Last Post: Jun 15th, 2005, 11:07 PM
  5. Should Business Objects have References to DAOs?
    By sethladd in forum Architecture
    Replies: 9
    Last Post: Aug 25th, 2004, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •