java.lang.ClassCastException: org.hibernate.mapping.ManyToOne cannot be cast to org.hibernate.mapping.Component

Stack Overflow | singe3 | 3 months ago
  1. 0

    ClassCastException when using nested mappedBy with Hibernate

    Stack Overflow | 3 months ago | singe3
    java.lang.ClassCastException: org.hibernate.mapping.ManyToOne cannot be cast to org.hibernate.mapping.Component
  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

    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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Memcached Java客户端2.6.1发布 - 编程语言 - ITeye资讯

    iteye.com | 1 year ago
    java.lang.ClassCastException: cannot be cast to
  6. 0

    ClassCastException in HandleFactory.getPkgFragmentRoot (355)

    Eclipse Bugzilla | 1 year ago | error-reports-inbox
    java.lang.ClassCastException: cannot be cast to org.eclipse.wst.jsdt.internal.core.PackageFragmentRoot

    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 cannot be cast to org.hibernate.mapping.Component

      at org.hibernate.mapping.PersistentClass.getRecursiveProperty()
    2. Hibernate
      CollectionSecondPass.doSecondPass
      1. org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:465)
      2. org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:421)
      3. org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:763)
      4. org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:724)
      5. org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:54)
      5 frames
    3. org.hibernate.boot
      MetadataBuildingProcess.complete
      1. org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1621)
      2. org.hibernate.boot.internal.InFlightMetadataCollectorImpl.processSecondPasses(InFlightMetadataCollectorImpl.java:1589)
      3. org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:278)
      3 frames
    4. org.hibernate.jpa
      EntityManagerFactoryBuilderImpl.build
      1. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:848)
      2. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:876)
      2 frames
    5. Spring ORM
      AbstractEntityManagerFactoryBean.afterPropertiesSet
      1. org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
      2. org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
      3. org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
      3 frames
    6. Spring Beans
      AbstractAutowireCapableBeanFactory.initializeBean
      1. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
      2. org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
      2 frames