[ROO-3884] Missing option for 'field set/list' command to declare if the mappedBy field is notnull Created: 26/Feb/17  Updated: 16/Jul/17

Status: Reopened
Project: Spring Roo
Component/s: PERSISTENCE
Affects Version/s: 2.0.0.M3
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Sebastian Theek Assignee: Juan Carlos García del Canto
Resolution: Unresolved Votes: 0
Labels: field, jpa, onetomay, reference
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


Currently there is no possibility to give an option to the 'field set/list' commands to declare that the mappedBy field in the child side, which holds the reference to the parent (in a ONE_TO_MANY relation), has to be notnull or not. At the moment the generated code ALWAYS is without @NotNull for the mappedBy field on the child side!

We would like to define an ONE_TO_MANY relation, where the child must have a foreign key set (often needed in real life). In previous spring roo versions this was possible via the 'field reference' command. But since this command is only for ONE_TO_ONE relations (I think this was introduced by ROO-3793) there is no way to do that for now.

Best regards!
Sebastian Theek

Comment by Juan Carlos García del Canto [ 27/Feb/17 ]

Sorry, I've just update this issue during the ROO-3885 resolution by mistake. I reopen this issue.

Comment by Juan Carlos García del Canto [ 27/Feb/17 ]

Hi @theek

I'm checking this issue and I think that you're right about that there's no option to specify if the child entity must specify a relation with the parent entity during persist.

All the Spring Roo 2.x proofs generates a relation between entities but is not mandatory to specify the parent entity to create a child entity. Ex: You could create a new Pet without assign any Owner

Nowadays, the provided --notNull parameter of the field set/list command affects to the collection field. I'm not sure if that is correct or not, or if we need an extra parameter that affects to the child relation or to the parent side....I need time to analyze this issue.

I'll provide you an answer about it ASAP.


Comment by Sebastian Theek [ 03/Mar/17 ]

Did you already analyze this issue? I think it's really important to declare if the mappedBy field is notnull. Because it's really base stuff...


Comment by Juan Carlos García del Canto [ 03/Mar/17 ]

Hi Sebastian,

This issue is not going to be part of the Spring Roo 2.0.0.RC1 release, so we don't start to analyze it yet.

But don't worry! By now, you could include the @NotNull annotation in the child side manually and continue working with Spring Roo without any problem


Comment by Sebastian Theek [ 16/Jul/17 ]

Thanks for your work around hint.
But I would like to ask, if this issue will be resloved? I still think it's really base stuff!

Generated at Wed Jul 15 09:53:58 UTC 2020 using Jira 8.5.4#805004-sha1:0444eab799707f9ad7b248d69f858774aadfd250.