Can a @ManyToOne JPA relation be null?
You need to set:
@ManyToOne(optional = true, fetch = FetchType.LAZY)
not optional=false
.
The @Column(nullable=true)
is to instruct the DDL generation tool to include a NULL
SQL column type constraint.
For more on optional
vs nullable
, check out this StackOverflow answer.
try this:
@JoinColumn(name = "subType_id", nullable = true)