Bugs item #595738, was opened at 2002-08-15 23:17
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=595738&group_id=22866

Category: JBossServer
Group: v3.0 Rabbit Hole
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Michael Lipp (mlipp)
Assigned to: David Jencks (d_jencks)
Summary: Failure if EntityBean overrides equals

Initial Comment:
Trying to port our project from JBoss 2.2.4 to 3.0.1 I
found a problem with EntityBeans that override equals.

Our EntityBeans are derived from domain classes that
are used in other contexts as well. We consider the
EntityBeans as a derivation that adds persistence and
remote access. Due to this modelling concept, the
domain classes implement equals and hashCode.

I scanned through the EJB specification again just now
and found nothing that forbids overriding
equals/hashCode for an EntityBean. 

However, it makes JBoss 3.0 fail, because the
CachedConnectionManager uses the EntityBean objects as
keys in a HashMap. Shouldn't this work with the
overridden methods? Not necessarily. The main reason
are the EntityBeans created for the finder methods.
They have no identity yet and thus get some dummy id.
This id is not unique and makes the retrieval of the
connection associated with the EntityBean fail
(objectToConnectionManagerMap.get(key), with key being
the EntityBean).

I might work around this and it may even work if JBoss
allocates only one EntityBean container for a specific
bean (i.e. never have two EntityBean objects with the
same primary key) and one for the finder methods.

But the general problem remains: the assumption made by
JBoss that the EntityBean (i.e. the container object
for some persistent data) derives its identity simply
from the Java object (as do Object.equals and
Object.hashCode) may not be made. No specification
prohibits an equals method that returns true for
EntityBeans with different primary keys!



----------------------------------------------------------------------

>Comment By: Michael Lipp (mlipp)
Date: 2002-08-16 09:04

Message:
Logged In: YES 
user_id=77125

I think an "easy" fix would be to use a HashMap that uses ==
instead of equals() when comparing the items with same
hashCodes (or at least in same "hashCode associated list")

----------------------------------------------------------------------

Comment By: David Jencks (d_jencks)
Date: 2002-08-16 03:35

Message:
Logged In: YES 
user_id=60525

Many thanks for finding out why these problems were occurring!

Fixed in cvs head and 3.0 , in 3.2 very shortly.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=595738&group_id=22866


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to