Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
vikram karne
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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
 
Sunil Dixit
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic