Details
-
Bug
-
Resolution: Done
-
Critical
-
JBossAS-3.2.6 Final
-
None
-
None
Description
SourceForge Submitter: andersengstrom .
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.