• Post Reply Bookmark Topic Watch Topic
  • New Topic

Urgent!! Help with primary key in BMP

 
Kate Wilson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm completely new to ejb and still trying to understand the concepts. I have a project due next wk. I need help in creating the entity bean.
I have a table like this:
Product
* productid
* releaseno
* pname
* pdesc
* category - foreignkey (from category table)
this is the sql: create table product (productid varchar(7), releaseno int(5), pname varchar(7), pdesc varchar(130), PRIMARY KEY (productid, releaseno));

I need to implement this in EJB using BMP (since my other sqls need to extract data from multiple tables). Can anyone tell me how to implement the primary key for this since I have 2 fields of a table together as a primary key? All the examples have only one field as the pkey and they use this field in the where clause.. in ejbLoad() method; how can I do the same with multiple fields?

I'm using MySQL db and weblogic app server. Front end is created using struts and value objects.
After creating the entity bean, I've to link it with my value objects.

Any help/suggestions/code snippets would really be appreciated.

Thanks,
Kate
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You create a single primary key class that has two fields. This primary key class will be what is held in the Entity context -- in your ejbLoad you can obtain that instance and use both values in the WHERE clause.

Kyle
 
Kate Wilson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you pls send some link where I can see an example of how this is implemented?

Thanks
Kate
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe that Richard Monson-Haefel's book covers the multi-part primary key case. Also this url gives a simple example of a Composite primary key.

Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!