Hi,
No problem. What I originally said was if you have many different types of
entity beans, and use session beans that work on them (common
model-controller pattern), your session bean functions will look something
like this:
public class TravelAgentBean
extends SessionBean
{
//this is what a function looks like if you use generic wrapper PKs
public void processTransaction(Integer aCustomerPK, Integer
aItineraryPK, Integer aCreditCardPK, Integer aAddressPK...);
//this is what a function looks like if you use custom class PKs
public void processTransaction(CustomerPK aCustomerPK, ItineraryPK
aItineraryPK, CreditCardPK aCreditCardPK, AddressPK aAddressPK...);
}
Now do you see the problem? The first function is not typesafe at all!
Sure, the arg names clearly label what the user should pass in, but
developer of this bean is basically counting on the competency of the user
to pass in the correct corresponding PK values without any compile-time
checks! Should a user make a mistake and swap two arguments, where will
this be caught? Chances are, it probably won't, and someone else will be
footing the bill for another's free vacation! Debugging can be a nightmare!
The moral of this is: sure, custom PKs require a little more effort (not
really much more... just have a custom classes that wrap Integers or
Longs!), but you will appretiate your efforts in the long run!
Gene
-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Shiv Kumar
Sent: Wednesday, August 02, 2000 4:14 AM
To: [EMAIL PROTECTED]
Subject: Re: int as Primary Key
Hi
One of the replies said that it would be unmanageable if you have a lot of
entity beans and a separate PK class is not used. Can you explain me more on
that?
Becuse, I dont really see any disadvantage in using java.lang.Integer or
other
wrapper classes for primary key fields. At least now I dont have to write my
own
PK classes (less bugs :-).
--
shiv
> > Hi all
> >
> > I have only one column of datatype 'int' as the primary key for my
entity
> > bean.
> > I have two options now :
> >
> > * Define a new class called BeanPK and specify the class name in
> > <prim-key-class> element in ejb-jar.xml
> >
> > * Define a container managed field of type java.lang.Integer in the
> > bean
> > class. In ejb-jar.xml specify the following
> >
> > <prim-key-class>java.lang.Integer</prim-key-class>
> > ..
> > <primkey-field>containerManagedFieldName</primkey-field>
> >
> > This way I can save writing a new PK class.
> >
> > Any advantages/disadvantages following either type?
> >
> > TIA.
__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com
===========================================================================
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".