I always tend to name my collection instance variable names after their type (e.g. Set<Address> addressSet = new HashSet<Address>(); ) instead of using a plural "-es" like suffix, which I think has a lot less sense (e.g. because of the nesting possibilities of groups).
A while ago I was astonished to notice Spring using the plural suffix naming strategy for generating names, as it doesn't feel like good practice, and now I stumbled upon bugs I think are caused by this strategy.
My domain model object:
generated PersonBean_Roo_ManagedBean.aj contains non-existing method names:Code:@RooJavaBean @RooToString @RooJpaActiveRecord public class Person extends AbstractEntity { private String firstName; private String name; private String initials; @ManyToOne private Nationality nationality; @ManyToMany(cascade = CascadeType.ALL) private Set<TradLanguage> languagueSet = new HashSet<TradLanguage>(); @ManyToMany(cascade = CascadeType.ALL) private Set<Address> addressSet = new HashSet<Address>(); @ManyToMany(cascade = CascadeType.ALL) private Set<PhoneNr> phoneNrSet = new HashSet<PhoneNr>(); }
andCode:public java.lang.String PersonBean.onEdit() { if (person != null && person.getTradLanguages() != null) { selectedLanguagueSet = new ArrayList<TradLanguage>(person.getLanguagueSet()); } if (person != null && person.getAddresses() != null) { selectedAddressSet = new ArrayList<Address>(person.getAddressSet()); } if (person != null && person.getPhoneNrs() != null) { selectedPhoneNrSet = new ArrayList<PhoneNr>(person.getPhoneNrSet()); } return null; }
while the declarations read:Code:public void CompanyBean.reset() { company = null; selectedTradLanguages = null; selectedAddresses = null; selectedPhoneNrs = null; createDialogVisible = false; }
So the method names in red are generated incorrectly as opposed by the green method names.Code:private List<TradLanguage> CompanyBean.selectedLanguagueSet; private List<Address> CompanyBean.selectedAddressSet; private List<PhoneNr> CompanyBean.selectedPhoneNrSet;
Do I create a Jira for this?
Best wishes,
Jochen
EDIT: I've found a similar though different code generation issue:
In my model I have 2 collections of street objects:
in the generated xxxBean_Roo_ManagedBean.aj it correctly generated:Code:@ManyToMany(cascade = CascadeType.ALL) private Set<Street> rightfulStreets = new HashSet<Street>(); @ManyToMany(cascade = CascadeType.ALL) private Set<Street> parkStreets = new HashSet<Street>();
though in these places it fails:Code:private List<Street> AreaBean.selectedRightfulStreets; private List<Street> AreaBean.selectedParkStreets;
andCode:public void AreaBean.reset() { area = null; selectedStreets = null; selectedStreets = null; createDialogVisible = false; }
Code:public java.lang.String AreaBean.onEdit() { if (area != null && area.getStreets() != null) { selectedRightfulStreets = new ArrayList<Street>(area.getRightfulStreets()); } if (area != null && area.getStreets() != null) { selectedParkStreets = new ArrayList<Street>(area.getParkStreets()); } return null; }



Reply With Quote
