Say I have the following tables in database:
id | ... (table a)
---+----
a1 | ...
a2 | ...
a_id | b_id (mapping table a and b)
-----+----
a1 | b1
a1 | b2
a2 | b2
id | value (table b)
---+------
b1 | "one"
b2 | "two"
I want to map a JPA entity with Hibernate for table a:
@Entity
class EntityA {
List<String> values;
}
so that values is "one", "two" for "a1" and "two" for "a2" in the example. I don't need an entity for table b, just a single column in table b to be included in EntityA, can this be done with @ElementCollection and how?