@Entity @Table(name="product") public class Product extends AbstractEntity { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; @ElementCollection(fetch = FetchType.EAGER) @JoinTable(name="product_attribute", joinColumns=@JoinColumn(name="product_id")) @MapKeyColumn(name="key") @Column(name="value") private Map<String, String> attributes = new HashMap<String, String>(); // ... } |
Generated additional table for product attributes (PostgreSQL example) will be like below.