I've been having some problems with the primary key class lately, and I have
looked for a book that really describes the process.  I found O'Reilly's
Enterprise JavaBeans devotes a lot of time to the subject if you are
intersted in picking it up.  I got it because it was recommended by the
website www.ejbnow.com .  To get the primary key class right, you are going
to need a good reference.

Basically you need to make sure that the primary key class has public member
variables that match exactly in type and name of the same fields in your
implementation bean.  The pk class must be serializable and implement the
equals and hashCode methods, and must have a default empty constructor.  I'm
not sure if it is required, but you also provide a constructor that contains
the key values.  The hashCode method I don't really know a lot about, but at
ejbnow.com, there is a tips page that describes how to code it.

In your ejb-jar.xml, make sure to not specify
<primkey-field>...</primkey-field>.  When you specify a custom
prim-key-class you don't need this entry, and it will mess you up.  Trust
me.  So if your primary key class is called CustomerPK, then your entry for
the class in ejb-jar.xml is ( assuming no package name )

<prim-key-class>CustomerPK</prim-key-class>

Then you need to specify your primary key class in the home interface in
findByPrimaryKey, and it must be the return type of all of your ejbCreates
in the bean implementation.

I think that covers it.  Good luck.

Scott

-----Original Message-----
From: Sivakumar_Subramanian
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 27, 2000 12:10 AM
To: [EMAIL PROTECTED]
Subject: Primary key class..


Hello All,
        Can anybody help me out how to implement the composite primary keys
with the code. I am struck with that. Also i have some problem in declaring
a field(which is primary in my db as char(10) type). and in my xml i mention
like
<prim-key-class>java.lang.String</prim-key-class>
<primkey-field>customerId</primkey-field>

in my ejb-jar file.

but it is giving error at the time of deployement.

pls help
-----------------------------------------------
Sivakumar Subramanian
Satyam Computer Services Ltd,
M.G. Road, Bangalore, India
EMail : [EMAIL PROTECTED]
Ph: 91-80-5597171 Extn: 3657
-----------------------------------------------

> ----------
> From:         Sharan, Abhishek[SMTP:[EMAIL PROTECTED]]
> Reply To:     A mailing list for Enterprise JavaBeans development
> Sent:         Tuesday, June 27, 2000 11:43 AM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Whether we can make JNI Calls from NAS4.0
>
> Hi Sridhar
>  i dont know much about NAS however there are some programming
> restrictions
> in EJB.
> Enterprise beans make use of the services provided by the EJB container,
> such as life-cycle management. To avoid conflicts with these services,
> enterprise beans are restricted from performing certain operations:
>             * Managing or synchronizing threads
> *       * Accessing files or directories with the java.io package
> * Using AWT functionality to display information or to accept information
> from a keyboard
> * Listening on a socket, accepting connections on a socket, or using a
> socket for multicast
> * Setting a socket factory used by ServerSocket, Socket, or the stream
> handler factory used by the URL class
> * Loading a native library
>
>  However it may be possible to do it NAS.you should explore other options
> rather that relying on application server specific
> functionality/feature
>
> HTH
> Abhishek
>
> > -----Original Message-----
> > From: Pydipati, Sridhar (CAP, FLEET)
> > [SMTP:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 27, 2000 7:14 AM
> > To:   [EMAIL PROTECTED]
> > Subject:      Whether we can make JNI Calls from NAS4.0
> >
> > Hi all,
> > We are trying to generate PDF documents from templates, we are trying to
> > make some native interface calls.
> >
> > We wanted to know whether we can make JNI calls ,and  if so what is the
> > Shared Library path for NAS, where we can put the DLLS for native
> > interface.
> >
> >
> > Appreciate your response.
> >
> > Thanks
> > Sridhar
> >
> >
> ==========================================================================
> > =
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> > body
> > of the message "signoff EJB-INTEREST".  For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to