Walter -

Thanks for the additional debug info.... I assumed that you were using a
DetachedStateManager, but I wanted to have you confirm for me.

The problem is that you are accessing an unloaded field while this Entity
is detached. I agree with you that we shouldn't be throwing an NPE... but
if we were to fix this NPE, OpenJPA would still have to ignore your
change[1]. I think your best best is to load the lazy collection prior to
streaming to the client. Another property you might want to look at is
openjpa.DetachState(AccessUnloaded=false). This property will throw an
exception when/if you try to access a field that isn't loaded.

Thanks,
Rick

[1]  [JSR-317 Final Release - pg 81] "The persistence provider must not
merge fields marked LAZY that have not been fetched: it must ignore such
fields when merging."
[2]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_detach_state

On Mon, Nov 14, 2011 at 3:33 AM, M. Walter <marc.wal...@sbb.ch> wrote:

> Hi Rick,
>
> sorry I wasn't right. The two entities are NOT being created at the client
> side but they are read from the server via RMI. Then the add() method of
> one
> of them is called in order to create a new ManyToMany relationship between
> these two entities. The add() method then calls the other entities' add()
> method and the NPE is raised (I showed you the line the exception occurs).
>
> We casted the entity to PersistenceCapable as you requested.
> In our JUnit integration test a
> com.ibm.ws.persistence.kernel.WsJpaStateManagerImpl state manager is used
> (this works).
> In our RCP client a org.apache.openjpa.kernel.DetachedStateManager state
> manager is used (this fails).
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Strange-behaviour-on-ManyToMany-relationship-using-RCP-client-tp6985422p6991859.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>



-- 
*Rick Curtis*

Reply via email to