Problem Inheritance and casting

From: Justin Deutsch (justin.deutsc..elevance.com.au)
Date: Wed Dec 22 2004 - 00:27:13 EST

  • Next message: Andrus Adamchik: "Re: Problem Inheritance and casting"

    Hi All,

    I'm having a problem with inheritance. I have the following tables,
    where I am using Type as object type:

       Role Role_Type
       ---- ---------
       ID ID
       Name Name
       Description Description
       Type -> Role_Type
       Rate

    and the following classes:

       Class Qualifier
       ----- ---------
       Role
       SystemRole type.name = "system"
       TimeSheetRole type.name = "timesheet"

    Everything seems to be working well, except when I try to retrieve a
    Role and test whether or not the role is an instance of TimeSheetRole,
    something like:

    r = Role.getRole(ctxt, VALID_TIMESHEET_ROLE_NAME);
    if(r instaceof TimeSheetRole){
       System.out.println("True");
    } else {
       System.out.println("False");
    }

    This statement would return False, not True as I'm expecting. Now I
    know that the VALID_TIMESHEET_ROLE_NAME is actually a TimeSheetRole,
    because my other test use the same value.

    Dose any one have any ideas what my problem is?

    Thanks in advance.

    -- 
    Justin Deutsch
    

    Relevance... because results count

    Relevance Phone: +61 (0)2 6241 6400 A.B.N. 86 063 403 690 Fax: +61 (0)2 6241 6422 Unit 11, Mobile: +61 (0)40 246 55 88 Cnr Brookes & Heffernan Sts, E-mail: Justin.Deutsc..elevance.com.au Mitchell ACT 2911 Web: http://www.relevance.com.au



    This archive was generated by hypermail 2.0.0 : Wed Dec 22 2004 - 00:27:27 EST