Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in persisting Entity with Composite Key

 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers

I am not able to persist entity with composite id. I am using JBoss 5.0.0. Below is the code of my entity.



I receive following exception



Please help

Thanks
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First check if you have the following class in your classpath

Caused by: java.lang.ClassNotFoundException: org.hibernate.exception.GenericJDBCException
 
Amirr Rafique
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remko Strating wrote:First check if you have the following class in your classpath

Caused by: java.lang.ClassNotFoundException: org.hibernate.exception.GenericJDBCException


I have added Hibernate3.jar in my classpath and above problem is solved but now it gives following exception


Please help

Thanks
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to have class with composit key fields , implementation of equals & hashcode method
And using that class as composit key with entity with @IdClass annotation.
@IdClass annotation is misssing with your entity.
 
Marcos Serrano
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a composite key...try creating a class with your 2 key fields (id and name) and implement that class into your entity.
 
Eswar Kaligotla
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This can be achieved by using either IdClass or Embeddable/EmbeddedId. Both are more or less same.
Let us all know what hapened after using IdClass or Embeddable.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic