I wish to map same column several times. In order to do so, the second mapping is read only. In most cases this approach works. However, in this case I got following error:
Repeated column in mapping for collection: Order.content column: item_id
Could you please help me to understand, what is wrog with my code:
@Entity
class Order {
...
@OrderColumn(name = "idx")
@JoinColumn(name = "order_id")
@ElementCollection(fetch = LAZY)
@CollectionTable(name = "order_content", schema = "orders")
private List<OrderContent> content;
}
@Embeddable
class OrderContent {
@JoinColumn(name = "item_id")
@ManyToOne(fetch = LAZY, targetEntity = Item.class)
private Long itemId;
@JsonIgnore
@ManyToOne(fetch = LAZY, targetEntity = Item.class)
@JoinColumn(name = "item_id", insertable = false, updatable = false)
private Item item;
}
Thank you.