Return-Path: X-Original-To: apmail-isis-users-archive@www.apache.org Delivered-To: apmail-isis-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 265C310225 for ; Thu, 12 Sep 2013 12:56:17 +0000 (UTC) Received: (qmail 54520 invoked by uid 500); 12 Sep 2013 12:56:17 -0000 Delivered-To: apmail-isis-users-archive@isis.apache.org Received: (qmail 54410 invoked by uid 500); 12 Sep 2013 12:56:16 -0000 Mailing-List: contact users-help@isis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@isis.apache.org Delivered-To: mailing list users@isis.apache.org Received: (qmail 53729 invoked by uid 99); 12 Sep 2013 12:56:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Sep 2013 12:56:15 +0000 X-ASF-Spam-Status: No, hits=2.6 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,URIBL_GREY X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [209.85.216.174] (HELO mail-qc0-f174.google.com) (209.85.216.174) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Sep 2013 12:56:10 +0000 Received: by mail-qc0-f174.google.com with SMTP id n9so3919614qcw.33 for ; Thu, 12 Sep 2013 05:55:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=cF+BzHYMk26HVenh3ecHzv0cXiAk1wyBRRUJ7JZZP88=; b=Zirl/UDg8jfiqOq7S+yrhRT0BtUt2pS2p8ix18o5j8MS+skMNPy06ovrFoC+sUVK0k jpUfAK6U7K8QgVq/CeYp46GQrc8gDNAviD4DtVnMAyY4LKoesJ9sTUX4ag3UnMQLtYrp UWHhJjB+F8oQ10tj0eKY/SLaWsiOGU7gNb8nA7Qhz2kZoyPBuq2XUSNF36w74QzLlPuD SEnPNo2p/2bC4Wlq6PkolpXkFx2XNpcet6PUFrrLM04KYmYmYCKG2HL2MrIG1eQ8ONbp fHKO5ruG4BwEpFYhRmkJatE4mptHegN2Y1GilEyqgMplBYHxHEBH6dkCRVtUJuWuDpkJ Kd+w== X-Gm-Message-State: ALoCoQnJtPFZ892LX45BCLmseRRhKc5s7pQkipX0WSjHlSqLcmtBtv8Sowxy1gLUY4EhqTnFq3D4 X-Received: by 10.49.3.194 with SMTP id e2mr13467825qee.21.1378990529828; Thu, 12 Sep 2013 05:55:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.49.64.70 with HTTP; Thu, 12 Sep 2013 05:55:09 -0700 (PDT) X-Originating-IP: [31.51.110.94] In-Reply-To: References: From: Dan Haywood Date: Thu, 12 Sep 2013 13:55:09 +0100 Message-ID: Subject: Re: NullPointerException when trying to persist a domain entity To: users Cc: dev Content-Type: multipart/alternative; boundary=047d7bb04734ae069c04e62f40c6 X-Virus-Checked: Checked by ClamAV on apache.org --047d7bb04734ae069c04e62f40c6 Content-Type: text/plain; charset=ISO-8859-1 Further to this, I've now changed the framework [1] so that simply newing up the object will work (rather than requiring newTransientInstance()) There are some (relatively minor) implications to this, in the ticket. I've also added Javadoc so that this is all more easily discoverable. Any questions/issues, let me know Cheers Dan [1] https://issues.apache.org/jira/browse/ISIS-528 On 10 September 2013 20:06, Jeremy Gurr wrote: > Yeah, using newTransientInstance to obtain the entity vs. newing one up > manually worked. Thanks. > > Automatic recovery would be nice to make it easier for newbies to get up > to speed with the framework. At a minimum, the javadoc for the persist > method should indicate that you can't just persist any data entity, but > that the entity must be obtained from the newTransientInstance method. > > > ________________________________________ > From: Dan Haywood [dan@haywood-associates.co.uk] > Sent: Tuesday, September 10, 2013 11:51 AM > To: users > Subject: Re: NullPointerException when trying to persist a domain entity > > How did you instantiate the transient object? Did you just new it up, or > did you use container.newTransientInstance()? > > I'm *hoping* the former. The right thing to do is the latter. > > If the above doesn't sort it out, then could you restate the problem but > using some different class names. I got a bit confused with your > description, which class is the persistable entity (cf Customer), which > class is the domain service (cf CustomerRepo). > > I agree that we should improve the error messages here. We might even try > to automatically recover from the situation (by creating the adapter lazily > if not present) if we are passed a pojo that was created "outside" of the > container. Off the top of my head, I can't see why that won't work (but I > might be forgetting something). > > Cheers > Dan > --047d7bb04734ae069c04e62f40c6--