Announcement Announcement Module
No announcement yet.
New Roo scaffolding does not work with String ids Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • New Roo scaffolding does not work with String ids

    I created a new roo project and built out my entities. One of my entities is a small table (< 75 records) with a set of string columns that are candidate keys.
    The strings are 5-10 characters so I thought they make a good primary key. So I shifted the @Id annotation to my String column called accountNumber.

    This works pretty well and the jspx scaffolding and controllers still work. The only problem is that if the string contains a "/", it is not encoded for urls when building the links inf the scaffolding.

    For instance, Here is the generated controller method for responding toe the create form from the roo scaffolding:
    @RequestMapping(method = RequestMethod.POST)
        public String create(@Valid GeneralLedger generalLedger, BindingResult result, Model model) {
    		if (result.hasErrors()) {
                model.addAttribute("generalLedger", generalLedger);
                return "generalledgers/create";
            return "redirect:/generalledgers/" + generalLedger.getAccountNumber();
    if your notice the last line of this method youwill notice whatever is in the accountNumber field is append as raw text to "redirect:/generalledgers/". If the account code is "a/r", then the return string is "redirect:/generalledgers/a/r" which obviously is not going to go to a real controller method. What should have returned is "redirect:/generalledgers/a%2fr". Even if you make the change to encode the url yourself, all of the jspx scaffolding needs ot be updated as well. In my mind there is no risk of encoding all keys in spring roo. Numbers are not altered when they are encoded. So why does spring roo not encode the keys?