1

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.

  • Possible duplicate of [Another Repeated column in mapping for entity error](http://stackoverflow.com/questions/15076463/another-repeated-column-in-mapping-for-entity-error) – PseudoAj May 18 '16 at 00:10
  • Thank you for the answer, but unfortunately its not the same case. I already declared second mapping as read only. With entities, this works fine. My problem ether with a collection or with @Embedable. And I cannot find any workaround. –  May 18 '16 at 00:36

0 Answers0