You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed that when using embeddables that they are always created in the entity not matter what. For example, a User has a PhoneNumber(embeddable) and the PhoneNumber only has one field, "value". If it's reasonable for a User to not have a PhoneNumber in the system, then I don't believe a PhoneNumber instance should be created for the User entity when hydrated. If the value object's class has a **toString() method then you are forced to check if the value is null and if it is then return an empty string which is very hacky.
I propose to add a new "nullable" option to embeddables. If all of the columns that make up the embedded object are null then the embedded object should not be created if "nullable" is set to true.
Here's a gist illustrating the problem and the possible solution in yml.
Jira issue originally created by user dadamssg:
I've noticed that when using embeddables that they are always created in the entity not matter what. For example, a User has a PhoneNumber(embeddable) and the PhoneNumber only has one field, "value". If it's reasonable for a User to not have a PhoneNumber in the system, then I don't believe a PhoneNumber instance should be created for the User entity when hydrated. If the value object's class has a **toString() method then you are forced to check if the value is null and if it is then return an empty string which is very hacky.
I propose to add a new "nullable" option to embeddables. If all of the columns that make up the embedded object are null then the embedded object should not be created if "nullable" is set to true.
Here's a gist illustrating the problem and the possible solution in yml.
https://gist.github.com/dadamssg/25714381e97220147ce2
The text was updated successfully, but these errors were encountered: