File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Duplicate collection role mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Duplicate collection role mapping" Watch "Duplicate collection role mapping" New topic

Duplicate collection role mapping

Ashish Yannam

Joined: Sep 05, 2007
Posts: 19

I am new to Hibernate and i am tying to build a sample Hibernate application using the one given at

I am using eclipse to build this project.

I am having to tables, viz. book and customer. I have written a test code to save each of these objects in the DB.

The entity mapping files are similar, as mentioned in the tutorial.

But when I try to save these objects using,
I am getting the following exception

Can please anyone guide me on this.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Can you show us how you configure your SessionFactory?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ashish Yannam

Joined: Sep 05, 2007
Posts: 19
Its an auto generated file form eclipse.
The HibernateSessionFactory is also auto generated.

Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Sounds to me like the Book class isn't mentioned in the configuration file. You're using mapping files, right? Each Java class that acts as an entity must be mentioned in the mappings section of the configuration file.

-Cameron McKenzie
Ashish Yannam

Joined: Sep 05, 2007
Posts: 19
I am having entries for both the hbm.xml file in the hibernate.cfg.xml file.

here's the cfg.xml file

I agree. Here's the link:
subject: Duplicate collection role mapping
It's not a secret anymore!