Re: ClassCastException, Cayenne 2.0.4

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Mon Sep 08 2008 - 04:29:07 EDT

  • Next message: Ian Boston: "Re: ClassCastException, Cayenne 2.0.4"

    On Sep 8, 2008, at 11:18 AM, Ian Boston wrote:

    > Fantastic, thank you.
    >
    > One last question:
    > is this because Cayenne does introspection on the methods of the Db
    > entity class ?
    >
    > Since setAddresses is part of the Person API, (so I cant change it)
    > I assume that changing the name of the underlying attribute will
    > also fix this ?
    >
    > Ian

    Not sure I understand the question. So I maybe answering something you
    already know. What happens is that DbPerson.setAddresses(..) calls
    BaseCayenneShindigData.setList(..) method which in turn calls.
    'Cayenne.DataObject.addToManyTarget("addresses", Address).
    'addToManyTarget' is a generic method so it doesn't do any type
    checking, letting Address slip through where DbPersonAddress object is
    expected.

    So I guess when you are creating the test data, you need to create
    Address objects as well as DbPersonAddress objects explicitly and
    connect DbPersonAddress objects with DBPerson.

    Andrus



    This archive was generated by hypermail 2.0.0 : Mon Sep 08 2008 - 04:29:41 EDT