This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Hibernate Mapping Issue in Many to Many Relationship  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Because of not appearing hibernate annotations by using hibernate reverse engineering, I have to define all classes based on database schemas in the database.

I defined all mapping class in the hibernate.cfg.xml.      



Here are the essential files including book,orders,orderdetail and orderdetailid.

Book class


Order class



Order Detail class


OrderDetailId class


Where did I do thing wrong.

How can I fix it?

I'll appreciate if you can help me.

Thank you.
 
Ranch Hand
Posts: 530
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did the same, and this is the working version on my side. For your reference (I remove unrelated code such as some unrelated fields, constructors, equals, hashcode... for the brevity):

Book.java:



BookOrder.java:

 
Nam Ha Minh
Ranch Hand
Posts: 530
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Continue...
OrderDetail.java:



OrderDetailId.java:



I hope this helps. I made that code based on these tutorials:

  • Hibernate Many-to-Many Association Annotations Example
    Hibernate Many-to-Many Association with Extra Columns in Join Table Example

  •  
    Not so fast naughty spawn! I want you to know about
    global solutions you can do at home or in your backyard
    https://www.kickstarter.com/projects/paulwheaton/better-world-boo
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!