I'm trying to bind a table looks like this
some_id BIGINT PK
parent_id BIGINT NN '0'
As you can see,
- It looks like a self-referencing entity
- No FK for
parent_id
parent_id
is not nullable and defaults to0
How can I bind?
Does following mapping just fine?
class Some {
@Id
private Long id;
@ManyToOne // optional?
@JoinColumn(name = "parent_id", referencedColumnName = "some_id")
private Some parent;
}
How, in other words, can I map 0
to null
?