Hi!

Arno Schatz wrote:
> I just saw in AccountEJB.java of the pet store example that they store the
> primary key in an instance variable userId and use it only in method
> getDetails(). On other places in the same file they use
> context.getPrimaryKey(). From my understanding it should always use
> context.getPrimaryKey(). Somebody knows how it should be?

Tricky one. If you're doing BMP beans then storing it in an instance
variable is a great way of shooting yourself in the foot way too easily
(i.e. don't do it). OTOH, if you're doing CMP you have no choice but to
store it in instance variables, but at least the variable will always be
properly updated to contain the same value as getPrimaryKey() returns.

So:
If BMP -> AVOID!
If CMP -> No choice; you have to do it.

/Rickard

--
Rickard �berg

@home: +46 13 177937
Email: [EMAIL PROTECTED]
http://www.dreambean.com
Question reality

===========================================================================
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