• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic