On Thu, 2004-03-18 at 12:07, S, Shanthi (Cognizant) wrote: > In the persistence tag we can only define the table name at the class level and > the colunm name and the sql and jdbc type at the method level > > In the ejb.bean tag for the attribute "primkey-field" what is the value that needs > to be given?
Short answer: none, don't use it. Long answer: ... The primkey-field parameter of the class-level @ejb.bean tag is used to specify the optional primkey-field element in the deployment descriptor. It is only relevant when you have a single field as the PK (i.e. not a composite PK). To quote Sun's DTD for the DD: "The primkey-field element is used to specify the name of the primary key field for an entity with container-managed persistence. The primkey-field must be one of the fields declared in the cmp-field element, and the type of the field must be the same as the primary key type. The primkey-field element is not used if the primary key maps to multiple container-managed fields (i.e. the key is a compound key). In this case, the fields of the primary key class must be public, and their names must correspond to the field names of the entity bean class that comprise the key." If you're using a composite key, you don't need this element (and hence don't need the parameter on your @ejb.bean tag). Instead you use the method-level @ejb.pk-field tags to identify the fields which make up the PK, and the entitypk task generates a suitable class for you. > Otherwise the primary key entry has to be made manually to the ejb-jar.xml everytime > the code changes. Like I said, the primkey-field element is optional, so you don't *have* to add it manually every time something changes. Moreover, if you're using a composite PK, which (one) field would you specify as the PK field anyway? The prim-key-class element in the DD, on the other hand, needs to be there for both single fields and composite PKs; it tells the container what class the bean's PK is. For a composite PK, this will be the classname of the generated PK class. For a single PK field (i.e. specified using the primkey-field parameter), it will be that field's type. Either way, though, XDoclet will add it automatically so you don't need to worry about it. Andrew. > > Regards > Shanthi > > -----Original Message----- > From: Andrew Stevens [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 18, 2004 3:29 PM > To: [EMAIL PROTECTED] > Subject: Re: [Xdoclet-user] Composite Primary Key > > > On Thu, 2004-03-18 at 08:58, Konstantin Priblouda wrote: > > --- "S, Shanthi (Cognizant)" > > <[EMAIL PROTECTED]> wrote: > > > Hi Everybody, > > > > > > I have an entity bean which composes of composite > > > primary key, but what are the tags in xdoclet by > > > which a composite key can be defined. > > > > > > xdoclet supports only class as composite key, so > > tag getter of your composite key with > > @hibertate.composite-id , > > set generator to assigned and tag properties of > > respective class. > > Hibernate? He said he was using entity beans... > > Shanthi, you'll need to use ejbdoclet's <entitypk> subtask, and tag the relevant > getters in your bean class with @ejb.pk-field as well as the usual persistent field > tag. See > http://xdoclet.sourceforge.net/tags/[EMAIL PROTECTED](0..1) > > > Andrew. ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
