I have a table with the foreign key of another table (many-to-one relationship), but I want it to be zero.
Something like that:
public class SubType() { @Id @GeneratedValue(generator = "system-uuid") @GenericGenerator(name = "system-uuid", strategy = "uuid") private String id; } public class TopUp { @Column(nullable = true) @ManyToOne(optional = false, fetch = FetchType.LAZY) private SubType subType; }
But @Column(nullable = true) throws a NullPointerException and says that the subtype cannot be null. Is there a way to get ManyToOne to accept null?
java hibernate jpa hibernate-mapping many-to-one
Narges
source share