I am trying to perform a self-reference mapping (parent/child-like relationship) mapping to one table.
What I am trying to have is two different entities from same table so that I could separate properties and so on. I was thinking about using a discriminator value but I can’t because my database is already defined as the following: to distinguish parent from child we have the column parent_id which is not null for a child type (parent_id is of course, the foreign key to the same table). There is no way to define discriminator value in the following way: if object is of parent type then discriminator value null child otherwise.
I was looking for solution and I am a little bit stuck. Maybe, I will end up using one entity with two properties referring to parent (not null for child, @ManyToOne) and list of child (@OneToMany null for child). But until then (the moment, I have to decide using one entity), I would like to ask if there is a work around to perform what I am trying to do.