-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Embedded Objects get set to null if all its members are null
PostPosted: Mon Apr 09, 2007 12:35 am 
Newbie

Joined: Tue Sep 19, 2006 4:48 pm
Posts: 10
I found this posting but have not found anything in the hibernate jira database. http://jira.jboss.com/jira/browse/HIBERNATE-50

I think this is a bug. Here is my example:

Code:
@Embeddable
public class EmbeddableOne implements Serializable {
   private String field1;
   ...
}
@Embeddable
public class EmbeddableTwo implements Serializable {
   private Boolean field1;
   ...
}
@Embeddable
public class EmbeddableThree implements Serializable {
   private Double field1;
   ...
}

@Entity
public class MyEntity implements Serializable {
   @Embedded
   private EmbeddableOne field1 = new EmbeddableOne();
   @Embedded
   private EmbeddableTwo field2 = new EmbeddableTwo();
   @Embedded
   private EmbeddableThree field3 = new EmbeddableThree();
   ...

   public EmbeddableThree getField3() {
      if (field3 == null) {
          field3 = new EmbeddableThree();
      }
      return field3;
   }
}




The first 2 embeddable have a string and a boolean respectively. If those columns on the database are null the embedded field is still initialized with an empty object.

However, the embeddables with only numbers such as double get initialized to null if all the columns in the db are null. So, I have to place a workaround in the getter to initialize if the value is null.

this seems inconsistent, so i suspect this is a bug.

thoughts?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.