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

Category: JBossServer
Group: None
Status: Open
Resolution: None
Priority: 9
Submitted By: Christian Riege (lqd)
Assigned to: Nobody/Anonymous (nobody)
Summary: equals is wrong on Local Interfaces

Initial Comment:
hi,

there's something really rotten in the JBoss world
regarding local interfaces: when I do a check for
equality between two local interfaces of Bean A and
Bean B , this check returns TRUE when the beans have
the same PK (although they have totally different
classes and underlying DB tables).

This only happens on local interfaces, remote
interfaces work just fine.

Testcase and sources is attached. Put testcase.jar in
your deploy directory; then do 'java test.Test' to see
output in server console.

JDK 1.4.0_02
OS: Win2k & Linux
Affected JBoss Versions: 3.0 CVS, 3.2 CVS and 4.0 CVS

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

Comment By: Sven van t Veer (svenveer)
Date: 2002-11-27 14:01

Message:
Logged In: YES 
user_id=644391

The EJB spec is clear on this IMHO. From page 120 we learn:
"If two entity objects have the same home and
the same primary key, they are considered identical."

and:

"A client can test whether two entity object references refer to 
the same entity object by using the isIdentical method."

and, more importantly:
"Alternatively, if a client obtains two entity object references 
from the same home, it can determine if they refer to the 
same entity by comparing their primary keys using the equals
method."

conclusion:
- equals on two local interfaces from different homes should 
always return false.
- equals om two primary keys from the same type (even if 
obtained from two different remote (or local remote interfaces) 
using getPrimaryKey may return true
- the result of equals on two local/remote interfaces is 
undefined.
- when comparing interfaces (local or remote) the bean 
developer should use isIdentical instead of equals.



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

Comment By: Christian Riege (lqd)
Date: 2002-11-27 12:45

Message:
Logged In: YES 
user_id=176671

well, i would expect that when I obtain two Entity Beans
from the same home with different PK's that the equals()
operation returns true only if their PK is the same.

but that is not the problem.

Beans obtained from different homes should _never ever_
return true on an equals operation IMHO: after all a
java.lang.String will never return 'true' on an equals
operation with e.g. a java.util.Collection. but this is the
current behaviour in case their PK's match.

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

Comment By: Seth Sites (thesitesman)
Date: 2002-10-17 19:24

Message:
Logged In: YES 
user_id=579275

>From EJB 2.0 Spec Section 9.8.5 Page 120:

if a client obtains two entity object references from the 
same home, it can determine if they refer to the same 
entity by comparing their primary keys using the equals
method.

I think the important part here is "from the same 
home".  Your testcase involves comparing object 
references obtained from different homes.  This 
behavior is not addressed in the spec, and therefore is 
undefined.  Maybe we should check, but if you obtained 
it from the same home, like the spec clearly addresses, 
then the behavior will be correct.

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

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


-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to