[jboss-jira] [JBoss JIRA] Commented: (HIBERNATE-50) Embedded Objects get set to null if all its members are null

Lajos Gathy (JIRA) jira-events at lists.jboss.org
Sat Mar 3 19:26:10 EST 2007


    [ http://jira.jboss.com/jira/browse/HIBERNATE-50?page=comments#action_12354913 ] 
            
Lajos Gathy commented on HIBERNATE-50:
--------------------------------------

Why add an unnecessarry property to your class? If you are looking for a workaround, a better solution is to modify the setter of the embedded attribute like this (according to my former example):

public void setSomeAttributes(EAttrs someAttributes) {
	this.someAttributes = (someAttributes == null) ? new EAttrs() : someAttributes;
}

My point is, a built-in solution is needed here instead of workarounds.

Steve,
do you think my former proposal about adding a boolean 'mandatory' field to @Embedded annotation which implements this functionality is solvable?

Thanks in advance.

> Embedded Objects get set to null if all its members are null
> ------------------------------------------------------------
>
>                 Key: HIBERNATE-50
>                 URL: http://jira.jboss.com/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
>         Assigned To: 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: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list