org.hibernate.MappingException: Repeated column in mapping for collection: com.kawoolutions.bbstats.model.Group.parents column: parent_ordinal_nbr

Hibernate JIRA | Karsten Wutzke | 5 years ago
  1. 0

    I'm using an order column for an @OrderColumn which is also part of a foreign key like: {code}@ManyToMany @JoinTable(name = "GroupLinks", joinColumns = {@JoinColumn(name = "parent_round_id", referencedColumnName = "round_id"), @JoinColumn(name = "parent_ordinal_nbr", referencedColumnName = "ordinal_nbr")}, inverseJoinColumns = {@JoinColumn(name = "child_round_id", referencedColumnName = "round_id"), @JoinColumn(name = "child_ordinal_nbr", referencedColumnName = "ordinal_nbr")}) @OrderColumn(name = "child_ordinal_nbr") private List<Group> children;{code} As you can see the order column "child_ordinal_nbr" is also an FK (and PK) in the join table. However, this fails with a mapping exception: {code}Caused by: org.hibernate.MappingException: Repeated column in mapping for collection: com.kawoolutions.bbstats.model.Group.parents column: parent_ordinal_nbr at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:340) at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:363) at org.hibernate.mapping.Collection.validate(Collection.java:320) at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:89) at org.hibernate.cfg.Configuration.validate(Configuration.java:1291) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1729) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ... 9 more{code} IMO there's no reason to assume the order column is not a foreign key column, too. I've posted an extensive example over at stackoverflow.com: http://stackoverflow.com/questions/9957247/is-manytomanymappedby-ordercolumn-supported-by-the-jpa While the JPA spec is silent about this behavior there's no reason why the depicted scenario shouldn't be working.

    Hibernate JIRA | 5 years ago | Karsten Wutzke
    org.hibernate.MappingException: Repeated column in mapping for collection: com.kawoolutions.bbstats.model.Group.parents column: parent_ordinal_nbr
  2. 0

    I'm using an order column for an @OrderColumn which is also part of a foreign key like: {code}@ManyToMany @JoinTable(name = "GroupLinks", joinColumns = {@JoinColumn(name = "parent_round_id", referencedColumnName = "round_id"), @JoinColumn(name = "parent_ordinal_nbr", referencedColumnName = "ordinal_nbr")}, inverseJoinColumns = {@JoinColumn(name = "child_round_id", referencedColumnName = "round_id"), @JoinColumn(name = "child_ordinal_nbr", referencedColumnName = "ordinal_nbr")}) @OrderColumn(name = "child_ordinal_nbr") private List<Group> children;{code} As you can see the order column "child_ordinal_nbr" is also an FK (and PK) in the join table. However, this fails with a mapping exception: {code}Caused by: org.hibernate.MappingException: Repeated column in mapping for collection: com.kawoolutions.bbstats.model.Group.parents column: parent_ordinal_nbr at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:340) at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:363) at org.hibernate.mapping.Collection.validate(Collection.java:320) at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:89) at org.hibernate.cfg.Configuration.validate(Configuration.java:1291) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1729) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) ... 9 more{code} IMO there's no reason to assume the order column is not a foreign key column, too. I've posted an extensive example over at stackoverflow.com: http://stackoverflow.com/questions/9957247/is-manytomanymappedby-ordercolumn-supported-by-the-jpa While the JPA spec is silent about this behavior there's no reason why the depicted scenario shouldn't be working.

    Hibernate JIRA | 5 years ago | Karsten Wutzke
    org.hibernate.MappingException: Repeated column in mapping for collection: com.kawoolutions.bbstats.model.Group.parents column: parent_ordinal_nbr
  3. 0

    Hibernate FK to itself not on primary key

    Stack Overflow | 4 years ago | Yervand Aghababyan
    org.hibernate.MappingException: Repeated column in mapping for entity: com.sflpro.dto.MyEntity column: ID (should be mapped with insert="false" update="false")
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    org.hibernate.MappingException: Could not determine type for: java.util.Collection, at table

    Stack Overflow | 10 months ago | MarwenBta
    org.hibernate.MappingException: Could not determine type for: java.util.Collection, at table: Region, for columns: [org.hibernate.mapping.Column(collection_actels)]

  1. kuldeep 16 times, last 3 months ago
  2. esaar 1 times, last 4 months ago
  3. r1chjames 1 times, last 6 months ago
  4. Kawada 6 times, last 6 months ago
  5. Harsh 1 times, last 8 months ago
34 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.hibernate.MappingException

    Repeated column in mapping for collection: com.kawoolutions.bbstats.model.Group.parents column: parent_ordinal_nbr

    at org.hibernate.mapping.Collection.checkColumnDuplication()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:340)
    2. org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:363)
    3. org.hibernate.mapping.Collection.validate(Collection.java:320)
    4. org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:89)
    5. org.hibernate.cfg.Configuration.validate(Configuration.java:1291)
    6. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1729)
    6 frames
  3. Hibernate EJB
    Ejb3Configuration.buildEntityManagerFactory
    1. org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
    2. org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)
    2 frames