[jboss-jira] [JBoss JIRA] Commented: (HIBERNATE-50) Embedded Objects get set to null if all its members are null
Vladimir Kovalyuk (JIRA)
jira-events at lists.jboss.org
Thu Jan 22 08:15:47 EST 2009
[ https://jira.jboss.org/jira/browse/HIBERNATE-50?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12449190#action_12449190 ]
Vladimir Kovalyuk commented on HIBERNATE-50:
--------------------------------------------
Found this in documentation:
The null value semantics of a component are ad hoc. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes.
One guy decided that erasure should be ok for most generics use for those days. Are you ok with erasure? Are most people ok with that?
I believe you should have a different look at the embeddable nature. You consider embedded object as a depended object. So you just strip regular entity to just entity without identity. It is limited point of view. OOD has the mixin class concept. It is very simple and very useful concept. What you have done is similar to dynamic mixin concept what is the expected echanement of static mixin in dynamic languages (Groovy for near instance). But you haven't started with static mixin concept which implies that all the fields are the part of resulted class. In other words you should have a not-null restriction for the component as default rule. And allow the developer to enable nullability for the component.
And just imagine how many side effects we obtain trying to work around this. If we try to force not-null for empty component we obtain pre-update events, useless updates and instance version changes and all the side effects caused by that. But if the component instance contains not-null value we don't have events invoked and updates. If the component has a field of primitive type we don't see any events and updates. Other workarounds causes more problems.
"... The null value semantics of a component are ..." completely inconsistent, theoretically not-proven and user-annoying feature.
> Embedded Objects get set to null if all its members are null
> ------------------------------------------------------------
>
> Key: HIBERNATE-50
> URL: https://jira.jboss.org/jira/browse/HIBERNATE-50
> Project: Hibernate
> Issue Type: Bug
> Environment: WinXP SP2, JBoss 4.0.4 GA as well as JBoss 4.0.5 GA, installation profile ejb3
> Reporter: milan w?lke
> Assignee: Steve Ebersole
>
> When having an embedded object only containing members of non-simple-types (e.g. String) and fetching it with the entity manager the following happens:
> If all columns, the embedded objects values are based on, are null the embedded object itself is set to null even if a non-arg-constructor set it to a non-null value before. A valid workaround is to include a member of a simple-type (e.g. int) in the embedded object. Doing this not all the values can be set to null, which results in not setting the embedded object itself to null, too.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list