• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Creation of CMP Entity bean with a Composite Primary Key???

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

i am having a composite primary keys in one of my table in the database.
I am trying to create a new entity bean for this table but i don't know how to create one in case when there is a composite primary key for a table.
Can anybody let me know is it possible to do it.
what is the procedure to be followed for the creation of the Entity bean in case of a composite primary key.

I am using MySql as the database .Creating CMP type of Entity bean.
Any help in this regard will be greatly useful to me as this is very urgent.

Thanks & Regards
Vikram K
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
It is possible in CMP and it is a peice of cake. You need to do following things :
1. create class which contains all required attribute of your composite PK and make it sure that this class implement serializable interface.
2. override equal and hashcode as per your business rule.
3. mention your class name with fully pkg name in descriptor of your entity.
4. I think tag called comp-pk ... but check in spec.

for eg.
class myPK implements Serializable
{
Intger col1;
String col2;
Inetger col3;
.... getter and setters
.. equals and hashcode....
}
hope that this help you...

Sunil
 
vikram karne
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Sunil

i will try to carry out the same procedure as you have said.


Regards
Vikram K
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic