Dec 3rd, 2010, 01:40 PM
Can't persist list with Hibernate
I feel this question has been asked and answered at least 100 times but I still don't see my way clearly. I have a simple setup. Table User, Table Organizations. 1 User can have many Organizations. I can populate a select box, make selections, traverse the int array, get the organizations, add them to list, call user.setOrganizations(myOrgSet);
I receive no errors, I also don't get my persistence of the set. If I make other changes on the form, those do get persisted but the list is ignored. Stepping through with the debugger, I am able to get and set the Organizations properly. I feel like everything is set correctly.
To the particulars: I am using Spring-webmcv-3.0.0.RELEASE.jar and Hibernate 3.
Things I have tried:
1. I have setup my onBind method. This works great for single objects, just not the set.
2. I have tried to setup an initBinder. I blindly copied an example. I didn't get a warm and fuzzy that it was either correct or actually being executed.
3. my hibernate mapping files have default-lazy="false";
4. Oddly, when I change my collection from Set to PersistentSet I get the following error:
"org.springframework.web.util.NestedServletExcepti on: Request processing failed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed"
I will be happy to provide any config files or code. I would be most appreciative if you could provide some points to try.
Thanks in advance!