Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 51751 invoked from network); 29 May 2009 07:13:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 May 2009 07:13:45 -0000 Received: (qmail 58239 invoked by uid 500); 29 May 2009 07:13:57 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 58193 invoked by uid 500); 29 May 2009 07:13:57 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 58183 invoked by uid 99); 29 May 2009 07:13:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 May 2009 07:13:57 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.78.103.231] (HELO vorsha.objectstyle.org) (208.78.103.231) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 29 May 2009 07:13:49 +0000 Received: (qmail 17466 invoked from network); 29 May 2009 07:13:05 -0000 Received: from unknown (HELO ?IPv6:::1?) (127.0.0.1) by localhost with SMTP; 29 May 2009 07:13:05 -0000 Message-Id: <82454ECA-A7BC-450D-9B27-203262323DF4@objectstyle.org> From: Andrus Adamchik To: user@cayenne.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v935.3) Subject: Re: Sometimes no data from Relation to small tables Date: Fri, 29 May 2009 10:12:59 +0300 References: X-Mailer: Apple Mail (2.935.3) X-Virus-Checked: Checked by ClamAV on apache.org 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) { > /* > * @WORKAROUND > */ > 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-