William,
I see you took personal offense to my response, which wasn't my intention.
Sorry, if you were insulted. I'm still convinced, however, that your
problem is fundamentally a limitation of the tool. The example works fine.
Anyway, the 2nd Edition of the book explains why I use compound primary keys
for even simple "int" keys. It was designed as teaching tool so that bean
developers could learn how to work with compound primary keys. In addition,
I felt at the time that compound primary keys provide a distinct advantage
even with single fields since they hide the physical manifestation of the
primary key in the database. Using single-field primary keys like Integer
types doesn't. The introduction of deferred primary keys in EJB 1.1
provided a better solution, but not all the vendors supported this option so
I decided not to use it.
The 3rd edition of the book (which you can review at
http://oreilly.techrev.org/ ) doesn't use compound primary keys very much
because its easier for developers new to EJB to use single-field keys. I
think this is a good improvement to the book. The third edition does take
advantage of deferred primary keys in EJB 2.0 CMP to allow encapsulation of
unknown primary keys, which is possible now because more vendors will be
supporting this option.
I hope that explanation is sufficient.
Thanks,
Richard
[EMAIL PROTECTED] wrote:
> Richard,
>
> First off I think you should be a bit more careful in proclaiming this
> to be some limitation in a tool or server (where the server aspect came
> I don't know). I have used JBuilder since EJB 1.1 prior to joining
> Borland and found it to be quite a productive EJB environment unlike
> the rest of the tools on the market. Note I have worked with WebLogic,
> Websphere, Silverstream and NetDynamics earlier on in my career.
>
> I have never encountered a problem with PKs used with ints or Integers
> within this environment. In fact Borland AppServer supports beans with
> primitives as PK's as do the deployment tools. JBuilder does not
> restrict the bean provider but maybe the db-to-ejb wizard does not
> always get it right especially when you use a PK which is simply
> wrapping a int. Possibly the wizard was simply saying why bother with
> this silly little pk class when you can have a Integer which already
> has a correct hashcode and equals implementation. It could be many
> things especially when its a wizard and the user is providing the input
> into the steps.
>
> Its good to see that you have moved away from this in your current book
> especially when they were not warranted in most cases though I do
> understand your motives, or was it a limitation in the tools and server
> you were using to write and test the examples with....... ;-)
>
> regards,
>
> William
>
> ----- Original Message -----
> From: Richard Monson-Haefel <[EMAIL PROTECTED]>
> Date: Tuesday, July 10, 2001 2:32 pm
> Subject: Re: Not 'int' but 'Integer' in Cabin example by Richard Monson-
> Haefel
>
> > Hi,
> >
> > Literally tens of thousands of people have run the examples in the
> > book with
> > out a problem. It must be a limitation of your tools and or
> > server. You can
> > change your examples to use Integer if that works better with your
> > tool.
> > Note: In the 3rd Edition of the book (http://oreilly.techrev.org/)
> > I also use
> > single-field primary keys a lot since that seems to be easier for
> > people new to
> > EJB. However, compound primary keys are still valuable in many cases.
> >
> > Thanks!
> >
> > Richard
> > --
> > Richard Monson-Haefel
> > Author of Enterprise JavaBeans, 2nd Edition (O'Reilly 2000)
> > Co-Author of Java Message Service (O'Reilly 2000)
> > http://www.jMiddleware.com
> >
> > Darya Said-Akbari wrote:
> >
> > > Hi,
> > >
> > > I wonder that anybody could run the Cabin example from
> > > chapter 4 of Richard Monson-Haefel EJB book.
> > >
> > > In the CabinPK class he use 'int' instead of 'Integer'
> > > for declaration. Shouldn't it be 'Integer' since
> > > CabinPK implements the Serializable interface?
> > >
> > > When you try it opposite, to model your Cabin EJB
> > > begining with your Database table CABIN, then the
> > > JBuilder4 wizard only use Integer instead of int.
> > >
> > > If anyone could run the example like given in the
> > > book,
> > > please let me know.
> > >
> > > Best regards,
> > > Darya
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Get personalized email addresses from Yahoo! Mail
> > > http://personal.mail.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".
> >
> >
--
Richard Monson-Haefel
Author of Enterprise JavaBeans, 2nd Edition (O'Reilly 2000)
Co-Author of Java Message Service (O'Reilly 2000)
http://www.jMiddleware.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".