This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Object Relational Mapping and the fly likes Item - Bid Unidirectional PROBLEM !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Item - Bid Unidirectional PROBLEM !!!" Watch "Item - Bid Unidirectional PROBLEM !!!" New topic
Author

Item - Bid Unidirectional PROBLEM !!!

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
I have a unidirectional association from Item -> Bid as one-to-many.

Item.java


Bid.java


In Item.hbm.xml



while in Bid.hbm.xml, i have no association mapping :

I am getting the following error :

10:47:05,860 INFO HbmBinder:300 - Mapping class: Bid -> BID
10:47:05,860 INFO Configuration:1538 - Configured SessionFactory: null
10:47:05,860 INFO HbmBinder:2375 - Mapping collection: org.hibernate.auction.model.Category.childCategories -> CATEGORY
Initial SessionFactory creation failed.org.hibernate.MappingException: Association references unmapped class: org.hibernate.auction.model.Bid
Exception in thread "main" java.lang.ExceptionInInitializerError
at util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at test.ItemBidTest.addBidToItem(ItemBidTest.java:34)
at test.ItemBidTest.main(ItemBidTest.java:24)
Caused by: org.hibernate.MappingException: Association references unmapped class: org.hibernate.auction.model.Bid
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2370)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2652)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1127)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 4 more
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

Initial SessionFactory creation failed.org.hibernate.MappingException: Association references unmapped class: org.hibernate.auction.model.Bid


Do you have any mapping for this class? If so, have you included it in the hibernate.cfg.xml?


[My Blog] [JavaRanch Journal]
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
As i said in Bid.hbm.xml, i have no association mapping
yes i have included Bid.hbm.xml in hibernate.cfg.xml..
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

And can you post the contents of the Bid.hbm.xml?
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
Bid.hbm.xml

Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

<class name="Bid" table="BID">


You have mapped this as a Bid class and are referring in some other hbm, as org.hibernate.auction.model.Bid.
[ August 31, 2007: Message edited by: Jaikiran Pai ]
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
Originally posted by Jaikiran Pai:


You have mapped this as a Bid class and are referring in some other hbm, as org.hibernate.auction.model.Bid.

[ August 31, 2007: Message edited by: Jaikiran Pai ]


Yes as i previosuly said, i am referring it in Item.hbm.xml as :




NOTE : I have defined the package as
<hibernate-mapping package="org.hibernate.auction.model">
Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
I got the problem :

In Bid.hbm.xml :

<hibernate-mapping>
<class name="Bid" table="BID">

Instead it should be

<hibernate-mapping package="org.hibernate.auction.model">
<class name="Bid" table="BID">

The package attribute was missing ....


Thanks Jaikiran
[ August 31, 2007: Message edited by: Sandeep Vaid ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Item - Bid Unidirectional PROBLEM !!!