You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by Walt Armour <Wa...@concur.com> on 2003/02/03 03:52:49 UTC

RE: Re[2]: BaseObject equals problem

That should work fine.  I would have implemented like this:

public boolean equals(Object o)
{
	if (!(o instanceof ThisClass))
	{
		return false;
	}

	... do whatever else ...
}

ThisClass would of course be the proper name for this class (it will be
generated in).  The initial null check is unnecessary because instanceof
returns false for a null object.

If you really like you can submit a patch otherwise I'll create a bug and
put a patch in later this week.


> -----Original Message-----
> From: Boris Bliznukov [mailto:blib@dsi.ru] 
> Sent: Sunday, February 02, 2003 2:06 PM
> To: Walt Armour
> Cc: 'Turbine Torque Users List'
> Subject: Re[2]: BaseObject equals problem
> 
> 
> Hello Walt,
> 
> Sunday, February 02, 2003, 9:10:38 PM, you wrote:
> 
> WA> They are not from the same table.  Class A is from table 
> A and Class B is
> WA> from table B.  They just happen though to have the exact 
> same primary key
> WA> values in this instance.  BaseObject would consider the 
> objects equal in
> WA> this case (and be wrong).
> 
> you right.
> I added following lines
> 
>     public boolean equals(BaseObject bo)
>     {
>         if (bo == null)
>         {
>             return false;
>         }
>         if( ! bo.getClass().instanceOf(this) ) 
>                 return false;
> 
> seams works fine ...
> should I submit a patch ;) How does it work with torque?
> 
> Boris./
> 
> >> -----Original Message-----
> >> From: Quinton McCombs [mailto:qmccombs@nequalsone.com] 
> >> Sent: Sunday, February 02, 2003 10:15 AM
> >> To: 'Turbine Torque Users List'; 'Boris Bliznukov'
> >> Subject: RE: BaseObject equals problem
> >> 
> >> 
> >> I am curious.  How is it that you have two objects from 
> the same table
> >> with the same primary key, yet they are different classes?  I 
> >> understand
> >> persisting multiple objects to the same table...  But how are you
> >> getting two different classes with the same primary key?
> >> 
> >> > -----Original Message-----
> >> > From: Boris Bliznukov [mailto:blib@dsi.ru] 
> >> > Sent: Saturday, February 01, 2003 5:40 PM
> >> > To: turbine-torque-user@jakarta.apache.org
> >> > Subject: BaseObject equals problem
> >> > 
> >> > 
> >> > Hello turbine-torque-dev,
> >> > 
> >> > I notice that if I have two tables A and B, each having one 
> >> > numerical primary key. So I will have two subclasses of 
> >> > BaseObject A and B. Now for example if I get object from 
> >> > table A with primary key 1. And object from table B with 
> >> > primary key 1.
> >> > 
> >> > A.equals(B) will return true ... I think it is wrong. It 
> >> > should return false.
> >> > 
> >> > Both A and B inherit equals from BaseObject and it only 
> >> > compares the value of the primary key if object passwd to 
> >> > equals is a subclass of BaseObject. I think it also should 
> >> > compare runtime class names. Am I wrong?
> >> > 
> >> > -- 
> >> > Best regards,
> >> >  Boris                          mailto:blib@dsi.ru
> >> > 
> >> > 
> >> > 
> >> 
> ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: 
> >> > turbine-torque-user-unsubscribe@jakarta.apache.org
> >> > For additional commands, e-mail: 
> >> > turbine-torque-user-help@jakarta.apache.org
> >> > 
> >> > 
> >> 
> >> 
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: 
> >> turbine-torque-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: 
> >> turbine-torque-user-help@jakarta.apache.org
> >> 
> 
> 
> 
> -- 
> Best regards,
>  Boris                            mailto:blib@dsi.ru
>