[Fwd: Re: Problem Inheritance and casting]

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

  • Next message: James A. Hillyerd: "Cayenne + Apache Axis (Web Services)"

    Whoops, I should check who things are going to, when I reply to lists.

    -------- Original Message --------
    Subject: Re: Problem Inheritance and casting
    Date: Thu, 23 Dec 2004 10:31:58 +1100
    From: Justin Deutsch <justin.deutsc..elevance.com.au>
    Organization: Relevance
    To: andru..bjectstyle.org
    References: <41C905B1.901080..elevance.com.au>
    <6261.143.165.201.47.1103724986.squirre..bjectstyle.org>

    On 23/12/2004 1:16 AM, Andrus Adamchik wrote:
    > Hi Justin,
    >
    > "Role.getRole(ctxt, VALID_TIMESHEET_ROLE_NAME)" executes one of your
    > queries, right.

    Whoops, I should have mentioned that. Yes, it does execute a query. In
    fact the getRole is a static method of Role that looks for a role by name.

    > So what is this query, and what SQL it generates?

    Hmmm,

    cayenne INFO [main 12-23 10:28:57] QueryLogger: Created connection
    pool: jdbc:postgresql://raselin:5432/corporate
            Driver class: org.postgresql.Driver
            Min. connections in the pool: 1
            Max. connections in the pool: 10
    cayenne INFO [main 12-23 10:28:57] QueryLogger: --- will run 1 query.
    cayenne INFO [main 12-23 10:28:57] QueryLogger: Opening connection:
    jdbc:postgresql://raselin:5432/corporate
            Login: doychi
            Password: *******
    cayenne INFO [main 12-23 10:28:57] QueryLogger: +++ Connecting: SUCCESS.
    cayenne INFO [main 12-23 10:28:57] QueryLogger: --- transaction started.
    cayenne INFO [main 12-23 10:28:58] QueryLogger: SELECT t0.active,
    t0.description, t0.name, t0.rate, t0.type, t0.id FROM public.role t0
    WHERE t0.name = ? [bind: 'Consultant'] - prepared in 30 ms.
    cayenne INFO [main 12-23 10:28:58] QueryLogger: === returned 1 row. -
    took 100 ms.
    cayenne INFO [main 12-23 10:28:58] QueryLogger: +++ transaction committed.

    > A few things to check: that there is at least one row returned (so
    > getRole() is not null),

    I know the role is not null, as the in the unit test I have a line
    before the if that checks that the name returned is the one asked for
    (And before you ask it does pass).

    > and that a query "resolvingInherited" property is true (it is by
    > default).

    I haven't mucked around with the inheritance resolving.

    <snip>
    >>
    >>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
    >
    >
    >
    >

    -- 
    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

    -- 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 - 19:13:04 EST