File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Problem in persisting Entity with Composite Key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Problem in persisting Entity with Composite Key" Watch "Problem in persisting Entity with Composite Key" New topic
Author

Problem in persisting Entity with Composite Key

Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
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


"Know where to find the solution and how to use it - that's the secret of success."
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
First check if you have the following class in your classpath

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


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Amirr Rafique
Ranch Hand

Joined: Nov 14, 2005
Posts: 324
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

Joined: Feb 24, 2009
Posts: 268
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

Joined: Jul 13, 2006
Posts: 46
You need a composite key...try creating a class with your 2 key fields (id and name) and implement that class into your entity.


toutes les jours
Eswar Kaligotla
Greenhorn

Joined: Oct 15, 2007
Posts: 3
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in persisting Entity with Composite Key