Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 32748 invoked from network); 2 Jun 2007 02:24:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jun 2007 02:24:59 -0000 Received: (qmail 99091 invoked by uid 500); 2 Jun 2007 02:25:02 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 99074 invoked by uid 500); 2 Jun 2007 02:25:02 -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 99065 invoked by uid 99); 2 Jun 2007 02:25:02 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2007 19:25:02 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of lachlan.deck@gmail.com designates 209.85.146.180 as permitted sender) Received: from [209.85.146.180] (HELO wa-out-1112.google.com) (209.85.146.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jun 2007 19:24:57 -0700 Received: by wa-out-1112.google.com with SMTP id v33so1888611wah for ; Fri, 01 Jun 2007 19:24:36 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=CJ0JcvPiN+a4ET6zlx9sRTIPzW4WxBOqzQGfiFvyK2AxKSm6fn1pwa/KVdYUg5DDAfhW/WVl502m/jgdtpuuX3wDYVwKK2x5HlHBKkknB7+hvCqEUJGfI/k5NsgMPhovUDeaTNSb7ppvn4izdMMmzQC80wex8i6G1wliDqClJL0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:in-reply-to:references:content-type:message-id:content-transfer-encoding:from:subject:date:to:x-mailer; b=o+nZYkPcftb+pCZAYVvbaIm3WEox1uDX/cIwOpr1tDCA6JEjZhGnypudqqImFl9Hj5gr0rcJ1vbteGt33m6Vb2QHmSxZcLrb19xABSTZfqmodzcpz/mZOqUblXSsL2f1ojJSbWTl1nZ/5i3bq1gCEfcoQfufCDib5fTvizKv2sA= Received: by 10.114.144.1 with SMTP id r1mr2460173wad.1180751076278; Fri, 01 Jun 2007 19:24:36 -0700 (PDT) Received: from ?10.0.0.1? ( [58.168.62.253]) by mx.google.com with ESMTP id v32sm433512wah.2007.06.01.19.24.34; Fri, 01 Jun 2007 19:24:35 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <5810EE13-99DB-4D15-8B59-FE29A5815795@gmail.com> Content-Transfer-Encoding: 7bit From: Lachlan Deck Subject: Re: weird problems with context Date: Sat, 2 Jun 2007 12:24:30 +1000 To: user@cayenne.apache.org X-Mailer: Apple Mail (2.752.2) X-Virus-Checked: Checked by ClamAV on apache.org Hi Marcin, On 02/06/2007, at 11:43 AM, Marcin Skladaniec wrote: > I'm having a strange problem. When executing this bit of code: > > List categories = aContext.performQuery(new SelectQuery > (Category.class)); > if (categories.size() != 0) { > for (int categoriesCount = 0; categoriesCount < categories.size(); > categoriesCount++) { > Category cat = (Category) categories.get(categoriesCount); > logger.debug("context equal ? " + cat.getObjectContext().equals > (aContext)); > } > } Try this: logger.debug("context equal ? " + aContext == cat.getObjectContext()); The spanner in the works here (on the server-side) is the use of the ObjectContextCallbackInterceptor (see bottom of http:// cayenne.apache.org/doc/lifecycle-callbacks.html) which doesn't override equals. Thus, you might also want to try: if (aContext instanceof ObjectContextCallbackInterceptor) logger.debug("context equal ? " + ((ObjectContextCallbackInterceptor) aContext).getContext() == cat.getObjectContext()); else logger.debug("context equal ? " + aContext == cat.getObjectContext()); (ps, svn up... I've added it to our ObjectContextCallbackInterceptor subclass ;-) But it'll be worth submitting a bugreport for this. > the contexts are not equal, and I cant find the reason why ! > > I found this problem, because the perPersist() callback is not > fired when I do > cat.getObjectContext().newObject(SomeEntity.class) > but it is when > aContext.newObject(SomeEntity.class) > to add complexity, postPersist() and other callbacks are fired in > both cases. with regards, -- Lachlan Deck