Hibernate Embedded/Embeddable非null异常

Fin*_*arr 6 embedded hibernate embeddable

在拥有类:

...
@Embedded
private LatLon location;
...
Run Code Online (Sandbox Code Playgroud)

在引用的类中:

@Embeddable
public class LatLon implements Serializable {
    private double lat;
    private double lon;
    ...
}
Run Code Online (Sandbox Code Playgroud)

当我尝试使用null值保存拥有类的实例时LatLon:

org.hibernate.PropertyValueException: not-null property references a null or transient value: com.*.location.

如何在拥有类中允许此值为null?我试过制作它Nullable并没有效果.

axt*_*avt 8

这是因为double你的embeddable类中有属性,所以Hibernate为它们生成的不是空列.将他们的类型更改为Double.