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?