• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Item - Bid Unidirectional PROBLEM !!!  RSS feed

 
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And can you post the contents of the Bid.hbm.xml?
 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bid.hbm.xml

 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<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
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!