Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Mapping issue with A Foreign key refering

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have the tables as in the screenshot above

Class are written as below


Note not added getter and setters

and test code as below



I am getting the below exception


i came to know i should have the 2 attributes in FilterAttribute class to hold the composite key.. But how can we do that?
 
Volodymyr Lysenko
Ranch Hand
Posts: 512
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have executed code you provided and I didn't get your exception.

Please provide code which really throws that exception.

You should not declare id property as primitive type.
Change type of id variable to Integer in all entities.

And provide @GeneratedValue annotation for each id variable. I set it to AUTO

This works with test code you provided.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic