a simple doubt in primarykey class

Discussions

EJB design: a simple doubt in primarykey class

  1. a simple doubt in primarykey class (4 messages)

    hai freinds,

    i have a doubt in writing a primary key class.
    a entity bean represents a row in database and this is identified through the findbyprimarykey method.

    i have a situation such that i had to use entity bean(BMP)
    in which i have ti retrieve the records from database. the two tables are:
    category_id is primary key in category
    category_id,subcategory_id is primary key in subcategory

    now i have to write the primary key class , can anybody suggest me how to write this class.

    with regards
    k.ramakrishna


     
  2. Are these two tables related to each other.
    If yes then write the primary key based on one master table.
    Find the other Primary key by using find by primary key and fill your holder of the BMP with the primary key of the other table which you can get from the SQL written for the find by primary key.
    To insert the records Insert into master table first and then in the child table.
    To remove the records ,remove from the child table first and then the master table.
  3. hello deepak,

    yes wo tables are related to each other with foreignkey refrence.please explain in breif about these lines :

    Find the other Primary key by using find by primary key and fill your holder of the BMP with the primary key of the other table which you can get from the SQL written for the find by primary key.

    waiting for reply...
    k.ramakrishna
    (kalavendi at yahoo dot com)
  4. Hi,
    I think what deepak says is you can have the primary key object with the category_id. Once you find the category_id using findByPrimaryKey() method you can always have the corresponding subcategory_id(you can get easily by writing an SQL query). Now you are having both category and subcategory id, so you can proceed.

    Am I right or missed out something.
  5. Hi,
    I think what deepak says is you can have the primary key object with the category_id. Once you find the category_id using findByPrimaryKey() method you can always have the corresponding subcategory_id(you can get easily by writing an SQL query). Now you are having both category and subcategory id, so you can proceed.

    Am I right or missed out something.