Primary key field in DeployementDescriptor

Discussions

EJB programming & troubleshooting: Primary key field in DeployementDescriptor

  1. Primary key field in DeployementDescriptor (3 messages)

    Friends,
    In EJB1.1 specification,Sun ask us to maintain the Primary key field name in Deployment Descriptor instead of writing Primary key class.

    Is it applicable for Container Managed Persistence only?
    Dont I use it for Bean Managed Persistence?

    Thanks
    Robot Selva
  2. Primary key field in DeployementDescriptor[ Go to top ]



    This actually depends on how u implement the primary key class. If its a wrapper type (Integer, String etc) u need to provide two things. ie <prim-key-class> and <primkey-field>
    in ur deployment descriptor for container managed persistence.

    If u implement a serialized class for the primary key, u have to mention only the
    <prim-key-class>. Here, the class fields has to have a one-one correspondence with that of the bean class fields.

    For Bean managed persistence u dont write anything in the deployment descriptor. Everything is managed in the code.

    Regards

    Kumar
  3. Primary key field in DeployementDescriptor[ Go to top ]

    Thanks for your response.
    This is what I expected..

    When I write Bean Managed persistence bean,Can I use <prim-key-class> and <primkey-field> in the Deployement descriptor instead of writing a primary key class..

    For example
    This entity bean is bean managed persistence.

    Home Interface name : CusHome
    Remote Interface name : CusRemote
    Bean name : Customer

    In deployment descriptor,I mention primary key class like this
    <prim-key-class>java.lang.String</prim-key-class>
    <primkey-field> custId </primkey-field>

    Is it possible?
    Thanks
    Robot selva
  4. Hi Majic Robot,

    As per EJB 1.1 specs in CMP you can it is optional to specify list of container-managed fields and specification of the primary key field also
    The optional primkey-field may be present in the descriptor if the entity’s persistency-type is Container. So you need not have to specify <primkey-field> custId </primkey-field> in ejb-jar.xml file.
    But at least one cmp-field element must be present in the descriptor if the entity’s persistency-type is Container, and none must not be present if the entity’s persistence-type is Bean.

    Cheers!!!
    Sanjay_Rathod@hotmail.com