Say I have the following data in Postgresql table entity_b, which has an array column of ids from table entity_a:
id | e_a_ids[]
---+----------
b1 | a1,a2,a3
b2 | a1,a3
I want to map in Hibernate these two entities with annotations:
@Entity
class EntityA {
Set<EntityB> entityBs;
}
@Entity
class EntityB {
Set<EntityA> entityAs;
}
I have found examples of custom hibernate type that works with array column, but those are for primitives not for another entity type. I can also use a normal id column instead of an array column with the traditional many to many method by introducing another mapping table, but thats not so much a question to ask here then.
How can a bidirectional mapping with an array column of ids for another entity be mapped in Hibernate for a Postgresql database tables?