This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Problem in persisting Entity with Composite Key

 
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
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • 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
 
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.
 
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.
 
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.

 
    Bookmark Topic Watch Topic
  • New Topic