开发者

Hibernate Embedded/Embeddable not null exception

开发者 https://www.devze.com 2023-02-19 01:27 出处:网络
In the owning class: ... @Embedded private LatLon location; ... In the referenced class: @Embeddable public class Lat开发者_如何转开发Lon implements Serializable {

In the owning class:

...
@Embedded
private LatLon location;
...

In the referenced class:

@Embeddable
public class Lat开发者_如何转开发Lon implements Serializable {
    private double lat;
    private double lon;
    ...
}

When I try to save an instance of the owning class with a null value for LatLon:

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

What can I do to allow this value to be null in the owning class? I have tried making it Nullable and that had no effect.


It's caused by the fact that you have double properties in your embeddable class, so that Hibernate generates not null columns for them. Change their types to Double.

0

精彩评论

暂无评论...
验证码 换一张
取 消