Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incomplete setter for set field+mappedBy

Scenario:

entity --class ~.domain.Team
entity --class Person
field reference --fieldName team --type Team
focus --class Team
field set --fieldName members --type Person --mappedBy team
controller all --package ~.web

This generates standard CRUD scaffolding for People and Teams. When creating/updating a Team, there is a list selector for members, but changes are not persisted.

A workaround for this is to change setMembers in Team_Roo_JavaBean.aj:

public void Team.setMembers(Set<Person> members) {
    this.members = members;
    for (Person person : members) {
        person.setTeam(this);
    }
}

(added loop to update all referenced People, need to update those dereferenced as well...)

Why are changes to this [boilerplate] code necessary?

like image 838
Markus Avatar asked Dec 19 '25 21:12

Markus


1 Answers

I think this is a known blocker Spring Roo bug: https://jira.springsource.org/browse/ROO-2365.

like image 57
abalogh Avatar answered Dec 22 '25 13:12

abalogh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!