oracle jpa不能插入null

wtlkbnrh  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(279)

我有下面的用户实体,用户的配置文件是可选的,当我保存没有配置文件的用户我得到这个错误
ora-01400:无法将null插入(“用户\实体“.”配置文件\ fk”)

@Entity
public class UserEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(generator = "user-uuid")
    @GenericGenerator(name = "user-uuid", strategy = "uuid2")
    private String userId;

    private String email;

    @OneToOne(optional = true, fetch = FetchType.LAZY)
    @MapsId
    @JoinColumn(name = "profile_fk", nullable = true, unique = true)
    private ProfileEntity profile;

}

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class ProfileEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(generator = "profile-uuid")
    @GenericGenerator(name = "profile-uuid", strategy = "uuid2")
    private String profileId;

    private String email;

}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题