Wednesday, April 4, 2012

org.hibernate.MappingException: Association references unmapped class


org.hibernate.MappingException: Association references unmapped class: Bid
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2503)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2782)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at util.SessionUtil.<clinit>(SessionUtil.java:10)
... 1 more


Reason: The mapping xml does not specify the class name correctly.


<bag name="bids" cascade="all">
<key column="ITEM_ID" />
<one-to-many class="Bid" />
</bag>

In the above collection mapping, the Bid class does not declared using full path.

Solution:

Enter the fully qualified class name of the collection target class (Bid).

<bag name="bids" cascade="all">
<key column="ITEM_ID" />
<one-to-many class="model.Bid" />
</bag>




No comments:

Post a Comment