All pastes #2464157 Raw Edit

Miscellany

public unlisted java v1 · immutable
#2464157 ·published 2013-10-08 15:43 UTC
rendered paste body
HTTP Status 500 - Could not write JSON: failed to lazily initialize a collection of role: web.entity.Boards.childBoxList, could not initialize proxy - no Session (through reference chain: web.entity.Boxes["parentBoard"]->web.entity.Boards["childBoxList"]); nested exception is org.codehaus.jackson.map.JsonMappingException: failed to lazily initialize a collection of role: web.entity.Boards.childBoxList, could not initialize proxy - no Session (through reference chain: web.entity.Boxes["parentBoard"]->web.entity.Boards["childBoxList"])@RequestMapping (value = "/box/create/{parent}/{parentId}/{boxType}/{boxTitle}", method=RequestMethod.GET)    public @ResponseBody Boxes createBox(ModelMap model,                                          @PathVariable(value="parent") String parent,                                          @PathVariable(value="parentId") String parentId,                                          @PathVariable(value="boxType") String boxType,                                          @PathVariable(value="boxTitle") String boxTitle                                          ){                //queue        //get user id from session (save id in session first)        //verify for privs of user if he can create box or not.                //create box in the parent board / box        Boxes box = new Boxes();        box.setTitle(boxTitle);        box.setType(boxType);        if(parent.equals("board")){            //do this in service rather here. / that is set parent of box.            Boards board = new Boards();            board = (Boards)( boardService.getBoardById(Long.valueOf(parentId)) ).getObject();            boxService.setParent(box, board);        }else if(parent.equals("box")){            Boxes parentBox = new Boxes();            parentBox = (Boxes)( boxService.getBoxById(Long.valueOf(parentId)) ).getObject();            boxService.setParent(box, parentBox);        }                Boxes savedBox = (Boxes)boxService.save(box).getObject();                        System.out.println("box saved title was "+ savedBox.getTitle());        return savedBox;    }==============@Service@Transactional(readOnly = true)public class BoxesServiceImpl implements BoxesService{@Transactional(readOnly = false)    public Boxes setParent(Boxes childBox, Boards parentBoard){            childBox.setParentBoard(parentBoard);            return childBox;    }        @Transactional(readOnly = false)    public Boxes setParent(Boxes childBox, Boxes parentBox){            childBox.setParentBox(parentBox);            return childBox;    }=================@Entitypublic class Boards {    @Id    @GeneratedValue    private Long id;    @OneToMany    @JoinTable (name = "boards_childboxes",             joinColumns = @JoinColumn(name="boardId"),             inverseJoinColumns = @JoinColumn(name="childBoxId")            )    private Collection<Boxes> childBoxList = new ArrayList<Boxes>();      @ManyToMany    private Collection<BoardPrivileges> boardPrivilegesList = new ArrayList<BoardPrivileges>();    @ManyToMany     private Collection <Users> userList = new ArrayList<Users>();@Entitypublic class Boxes {    @Id    @GeneratedValue    private Long id;    @ManyToOne    private Boards parentBoard;    @ManyToOne    private Boxes parentBox; // the root box will have parentBox == null;    @OneToMany    @JoinTable (name = "Boxes_childboxes",             joinColumns = @JoinColumn(name="BoxId"),             inverseJoinColumns = @JoinColumn(name="childBoxId")                )    private Collection<Boxes> childBoxList = new ArrayList<Boxes>(); // the last leaf box will have childBox == null;    @OneToMany    private Collection<Tasks> taskList = new ArrayList<Tasks>();    @ManyToOne        private String type; // vertical / horizontal    private String title;       @ManyToMany     private Collection <Users> userList = new ArrayList<Users>();