Re: Sometimes no data from Relation to small tables

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri May 29 2009 - 03:12:59 EDT

  • Next message: Juergen Saar: "Re: Sometimes no data from Relation to small tables"

    Strange. How is the relationship mapped? Is this a PK to dependent PK?

    Andrus

    On May 28, 2009, at 5:16 PM, Juergen Saar wrote:

    > Hi,
    >
    > there is strange behavior on 1:1 Relations where the target-table
    > has only a
    > small amount of data.
    > In this cases I can see in the logfile, that there is no select for
    > data at
    > all.
    >
    > I found a workaround ... I do an explizit select ... this works
    > but the relation always brings hollow object
    > perhaps it brings a little more understandin of the problem:
    >
    > One more thing: I turn caching off, because there is
    > more Software on the System that works with this data.
    >
    > The Code Sniplet:
    >
    > I overwrite the readProperty from CayenneDataObject
    > in my derived Class named MwareBusinessObject
    > the 'expressionForRelation' is a helper working on base og the
    > Cayenne-Configuration
    >
    > public Object readProperty(String propName) {
    > Object result = null;
    > try {
    > result = super.readProperty(propName);
    > ...
    > if (result != null) {
    > ...
    > } else if (result instanceof MwareBusinessObject) {
    > /*
    > *..ORKAROUND
    > */
    > MwareBusinessObject bobj = (MwareBusinessObject)
    > result;
    > if (bobj.getPersistenceState() ==
    > PersistenceState.HOLLOW) {
    > Expression ex =
    > CayenneUtils.expressionForRelation(this, propName);
    > SelectQuery query = new
    > SelectQuery(result.getClass(), ex);
    > List tmp = getDataContext().performQuery(query);
    > if (tmp.size() == 1) {
    > result = tmp.get(0);
    > }
    > }
    > }
    > }
    > } catch (Exception e) {
    > ...
    >
    >
    > My Cayenne-Version is 2.0.4
    >
    > Sorry for not having tested the Problem with Version 3
    > -Juergen-



    This archive was generated by hypermail 2.0.0 : Fri May 29 2009 - 03:14:12 EDT