• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic