java - Hibernate, Spring, Thymeleaf and Set vs List -


i learning spring, hibernate , thymeleaf. thymeleaf collections works lists , sets relationships in hibernate seem better managed sets. creates issue when posting list data server indexed workgroup.people[0] etc

so if hibernate entity uses like:

@entity public class workgroup {     @onetomany(mappedby = "workgroup", fetch = fetchtype.eager)     private set<people> people = new hashset<>(); 

the question how useable entity in thymeleaf?

currently if try persist (post) workgroup entity people form data sent server looks like:

workgroup.people[0].duedate:18/09/2017 workgroup.people[0].status:new workgroup.people[0].peopletext:abc123 workgroup.people[1].supervisor.id:3 workgroup.people[1].assignee.id:3 workgroup.people[1].duedate:18/09/2017 workgroup.people[1].status:new workgroup.people[1].peopletext:def456 workgroup.people[2].supervisor.id:4 workgroup.people[2].assignee.id:4 workgroup.people[2].duedate:18/09/2017 workgroup.people[2].status:new workgroup.people[2].peopletext:ghi789 

and controller:

    @postmapping("/peoplesubmit") public string submitplan(@valid @modelattribute workgrouppeople workgrouppeople, bindingresult bindingresult) {         workgroupservice.updateworkgrouppeople(workgrouppeople);         return "redirect:dashboard";     } } 

note have breakpoint on controllers first line, never gets there before exception thrown.

invalid property 'workgroup.people[0]' of bean class [com.exa.dto.wp]: illegal attempt property 'people' threw exception; nested exception org.springframework.beans.invalidpropertyexception: invalid property 'workgroup.people[0]' of bean class [com.exa.dto.wp]: cannot element index 0 set of size 0, accessed using property path 'people[0]' 

do need load workgroup , people workgrouppeopledto object stores people list? & manage relationship?

and why people use hibernate seem prefer sets (i understand differences list)

a concrete example great. thanks.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -