org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped entity: com.wotif.jaguar.domain.booking.Booking.bookingInvoices

Hibernate JIRA | Robert Watkins | 1 decade ago
  1. 0

    We have a large project that has recently started to use Hibernate Annotations. We have not migrated all the classes to use annotations yet, so we still have some (most) classes managed via the .hbm.xml files. When we upgraded to Hibernate 3.1.1 and Hibernate Annotations 3.1beta8, from beta7, (and fixing the compile errors from various annotation changes) we started getting errors related to collections. It turns out that we can not have a collection (one-to-many) in an annotated class that refers to a non-annotated class (managed by the .hbm.xml). This problem did not occur with Hibernate 3.1 and Annoations 3.1beta7. We will investigate to see if it occurs with Hibernate 3.1.1 and Annotations 3.1beta7. Example source: @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "booking") @OrderBy("id asc") public Set<BookingInvoice> getBookingInvoices() { return bookingInvoices; } Example error: org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped entity: com.wotif.jaguar.domain.booking.Booking.bookingInvoices at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:703) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:421) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:382) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35) at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:331) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1296) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:629) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1156) at com.wotif.jaguar.util.HibernateTestUtil.buildSesssionFactory(HibernateTestUtil.java:131) ... 18 more

    Hibernate JIRA | 1 decade ago | Robert Watkins
    org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped entity: com.wotif.jaguar.domain.booking.Booking.bookingInvoices
  2. 0

    We have a large project that has recently started to use Hibernate Annotations. We have not migrated all the classes to use annotations yet, so we still have some (most) classes managed via the .hbm.xml files. When we upgraded to Hibernate 3.1.1 and Hibernate Annotations 3.1beta8, from beta7, (and fixing the compile errors from various annotation changes) we started getting errors related to collections. It turns out that we can not have a collection (one-to-many) in an annotated class that refers to a non-annotated class (managed by the .hbm.xml). This problem did not occur with Hibernate 3.1 and Annoations 3.1beta7. We will investigate to see if it occurs with Hibernate 3.1.1 and Annotations 3.1beta7. Example source: @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "booking") @OrderBy("id asc") public Set<BookingInvoice> getBookingInvoices() { return bookingInvoices; } Example error: org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped entity: com.wotif.jaguar.domain.booking.Booking.bookingInvoices at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:703) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:421) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:382) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35) at org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:331) at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1296) at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:629) at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1156) at com.wotif.jaguar.util.HibernateTestUtil.buildSesssionFactory(HibernateTestUtil.java:131) ... 18 more

    Hibernate JIRA | 1 decade ago | Robert Watkins
    org.hibernate.AnnotationException: Collection of elements must not have mappedBy or association reference an unmapped entity: com.wotif.jaguar.domain.booking.Booking.bookingInvoices
  3. 0

    Spring Boot JTA Error

    Stack Overflow | 2 years ago
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    query regarding one to many relationship in hibernate

    Stack Overflow | 2 years ago | arjun narahari
    org.hibernate.AnnotationException: Illegal attempt to map a non collection as a @OneToMany, @ManyToMany or @CollectionOfElements: com.hibernate.arjun3.Author.book
  6. 0

    embeddable mappedBy issue

    GitHub | 3 years ago | priyeshgpatel
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in resource loaded from byte array: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: blPU] Unable to build EntityManagerFactory

  1. davidvanlaatum 2 times, last 2 months ago
  2. r1chjames 1 times, last 6 months ago
  3. Kawada 108 times, last 7 months ago
  4. tjago 4 times, last 8 months ago
43 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.AnnotationException

    Collection of elements must not have mappedBy or association reference an unmapped entity: com.wotif.jaguar.domain.booking.Booking.bookingInvoices

    at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:703)
    2. org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:421)
    3. org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:382)
    4. org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
    5. org.hibernate.cfg.annotations.CollectionBinder.bind(CollectionBinder.java:331)
    6. org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1296)
    7. org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:629)
    8. org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:276)
    9. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:210)
    10. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1156)
    10 frames
  3. com.wotif.jaguar
    HibernateTestUtil.buildSesssionFactory
    1. com.wotif.jaguar.util.HibernateTestUtil.buildSesssionFactory(HibernateTestUtil.java:131)
    1 frame