java.lang.ClassCastException: org.hibernate.mapping.ManyToOne

Hibernate JIRA | Christian Bauer | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Collection (inverse) side: class User { @OneToMany(mappedBy = "buyer") @JoinTable(table = @Table(name = "ITEM_BUYER"), joinColumns = { @JoinColumn( name = "USER_ID") }, inverseJoinColumns = @JoinColumn(name = "ITEM_ID") ) private Set<Item> boughtItems = new HashSet<Item>(); } Other side: @SecondaryTable(name = "ITEM_BUYER", join = { @JoinColumn(name="ITEM_ID") } ) public class Item { @ManyToOne @JoinColumn(secondaryTable = "ITEM_BUYER", name = "USER_ID") private User buyer; } Exception: 19:44:04,766 DEBUG CollectionSecondPass:33 - Second pass for collection: org.hibernate.ce.auction.model.User.boughtItems 19:44:04,776 DEBUG CollectionBinder:673 - Binding a OneToMany: org.hibernate.ce.auction.model.User.boughtItems through an association table 19:44:04,790 ERROR HibernateUtil:80 - Building SessionFactory failed. java.lang.ClassCastException: org.hibernate.mapping.ManyToOne at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:708) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:410) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:371) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1030) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:227) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145) I'm also missing a mechanism to make the ManyToOne inverse, so I could have an indexed collection.

    Hibernate JIRA | 1 decade ago | Christian Bauer
    java.lang.ClassCastException: org.hibernate.mapping.ManyToOne
  2. 0

    Collection (inverse) side: class User { @OneToMany(mappedBy = "buyer") @JoinTable(table = @Table(name = "ITEM_BUYER"), joinColumns = { @JoinColumn( name = "USER_ID") }, inverseJoinColumns = @JoinColumn(name = "ITEM_ID") ) private Set<Item> boughtItems = new HashSet<Item>(); } Other side: @SecondaryTable(name = "ITEM_BUYER", join = { @JoinColumn(name="ITEM_ID") } ) public class Item { @ManyToOne @JoinColumn(secondaryTable = "ITEM_BUYER", name = "USER_ID") private User buyer; } Exception: 19:44:04,766 DEBUG CollectionSecondPass:33 - Second pass for collection: org.hibernate.ce.auction.model.User.boughtItems 19:44:04,776 DEBUG CollectionBinder:673 - Binding a OneToMany: org.hibernate.ce.auction.model.User.boughtItems through an association table 19:44:04,790 ERROR HibernateUtil:80 - Building SessionFactory failed. java.lang.ClassCastException: org.hibernate.mapping.ManyToOne at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:708) at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:410) at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:371) at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1030) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:227) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145) I'm also missing a mechanism to make the ManyToOne inverse, so I could have an indexed collection.

    Hibernate JIRA | 1 decade ago | Christian Bauer
    java.lang.ClassCastException: org.hibernate.mapping.ManyToOne
  3. 0

    Hibernate and @JoinFormula: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column

    Stack Overflow | 4 years ago | Ben
    java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Error while using @AttributeOverride in my Sub Entity class

    Stack Overflow | 3 years ago | user3607500
    java.lang.ClassCastException: org.hibernate.mapping.JoinedSubclass cannot be cast to org.hibernate.mapping.RootClass

    5 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. java.lang.ClassCastException

      org.hibernate.mapping.ManyToOne

      at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass()
    2. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:708)
      2. org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:410)
      3. org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:371)
      4. org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:35)
      5. org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1030)
      6. org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:227)
      7. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145)
      7 frames