You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by Dan Haywood <da...@haywood-associates.co.uk> on 2013/09/12 14:55:09 UTC

Re: NullPointerException when trying to persist a domain entity

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 <je...@infusionsoft.com> 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
>