Bugs item #800345, was opened at 2003-09-04 03:14
Message generated for change (Settings changed) made by starksm
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=800345&group_id=22866

>Category: JBossServer
Group: v3.2
Status: Open
Resolution: Duplicate
Priority: 7
Submitted By: Anders Engstr�m (andersengstrom)
>Assigned to: Scott M Stark (starksm)
Summary: isIdentical on entity bean does not check type of bean

Initial Comment:
When calling isIdentical on en EJBLocalObject

representing an entity bean the method returns "true"

if both EJBLocalObject have the same primary key - no

check is performed to verify that the EJBLocalObject

represents the same type of entity bean.



Pseudo Code:

==============



// Bean1 and Bean2 are entities with a primary key of

type java.lang.Long





// Locate the homes

Bean1LocalHome beanHome1 = getBean1Home(); 

Bean2LocalHome beanHome2 = getBean2Home(); 



// Find entities 

Bean1Local bean1 = beanHome1.findByPrimaryKey(new Long(1));

Bean2Local bean2 = beanHome2.findByPrimaryKey(new Long(1));



if(bean1.isIdentical(bean1)){

  //This evaulates to true as expected

}



if(bean1.isIdentical(bean2)){

  // This is ALSO evaluated to true, event though bean1

and bean2 does not represent the same entity.

}



================



Looking at the source, the method Boolean

isIdentical(Object, Object) only checks if its

arguments are of type EJBLocalObject and proceeds by

checking the primaryKey of the objects.



This method should also verify that the two objects are

of the same bean class.

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

Comment By: Anders Engstr�m (andersengstrom)
Date: 2003-09-04 06:08

Message:
Logged In: YES 
user_id=345315

The behaviour equals for EJB's is "undefined" according to

the EJB spec (last paragraph in 9.8):



========

Note that the Enterprise JavaBeans architecture does not

specify �object equality� (i.e. use of the ==

operator) for entity object references. The result of

comparing two object references using the Java programming

language Object.equals(Object obj) method is unspecified.

Performing the

Object.hashCode() method on two object references that

represent the entity object is not guaranteed

to yield the same result. Therefore, a client should always

use the isIdentical method to determine

if two entity object references refer to the same entity object.

===========



This, OTOH, is not true when using "isIdentical". JBoss

should really verify that the two compared beans are of the

same type (this could be implemented using the patch #624402

which uses the JNDI-name of the beans to extend the

comparision).

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

Comment By: Christian Riege (lqd)
Date: 2003-09-04 05:01

Message:
Logged In: YES 
user_id=176671

see also bug #613214: equals is wrong on Local Interfaces

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

Comment By: Anders Engstr�m (andersengstrom)
Date: 2003-09-04 04:58

Message:
Logged In: YES 
user_id=345315

After a little digging around I found that this problem have

been reported previously - and there is even a patch

submited that would solve this issue:



Bug #613214, Patch #624402



This was a long time ago, and I'm really curious why that

issue is still open?

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

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


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to