FAQ
I am using 3.0 (final) and am having some issues using
context.createFromDataRow(...)

ObjectResolver is throwing an NPE on what looks like updating snapshots.



Code:

SQLTemplate template = .....

template.setFetchingDataRows(true);

...

List res = this.dataContext.performQuery(template);

Subject sub = (Subject)context.objectFromDataRow(Subject.class,
(DataRow)res.get(0), true);



Err:

java.lang.NullPointerException

at
org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResol
ver.java:117)

at
org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows
(ObjectResolver.java:94)

at
org.apache.cayenne.access.DataContext.objectsFromDataRows(DataContext.ja
va:597)

at
org.apache.cayenne.access.DataContext.objectFromDataRow(DataContext.java
:646)

...........



What, if anything am I doing incorrectly here? I have tried changing the
refresh, and most of the other API calls with no success?

Has this changed any in 3.0, as I see a few differences between the API
and the docs?

Search Discussions

  • Andrus Adamchik at Oct 7, 2010 at 7:06 am
    Hi Jeff,

    From the lines in the stack trace, looks like context.getObjectStore().getDataRowCache() returns null, causing an NPE downstream. Now wondering why that can happen... Are you serializaing/deserializaing your DataContext?

    Andrus

    On Oct 6, 2010, at 9:04 PM, Rorison, Jeff wrote:

    I am using 3.0 (final) and am having some issues using
    context.createFromDataRow(...)

    ObjectResolver is throwing an NPE on what looks like updating snapshots.



    Code:

    SQLTemplate template = .....

    template.setFetchingDataRows(true);

    ...

    List res = this.dataContext.performQuery(template);

    Subject sub = (Subject)context.objectFromDataRow(Subject.class,
    (DataRow)res.get(0), true);



    Err:

    java.lang.NullPointerException

    at
    org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResol
    ver.java:117)

    at
    org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows
    (ObjectResolver.java:94)

    at
    org.apache.cayenne.access.DataContext.objectsFromDataRows(DataContext.ja
    va:597)

    at
    org.apache.cayenne.access.DataContext.objectFromDataRow(DataContext.java
    :646)

    ...........



    What, if anything am I doing incorrectly here? I have tried changing the
    refresh, and most of the other API calls with no success?

    Has this changed any in 3.0, as I see a few differences between the API
    and the docs?
  • Jeff Rorison at Oct 7, 2010 at 4:05 pm

    Andrus Adamchik <andrus <at> objectstyle.org> writes:


    Hi Jeff,

    From the lines in the stack trace, looks like
    context.getObjectStore().getDataRowCache() returns
    null, causing an NPE downstream. Now wondering why that can happen... Are you
    serializaing/deserializaing your DataContext?

    Andrus
    On Oct 6, 2010, at 9:04 PM, Rorison, Jeff wrote:

    I am using 3.0 (final) and am having some issues using
    context.createFromDataRow(...)

    ObjectResolver is throwing an NPE on what looks like updating snapshots.
    Code:

    SQLTemplate template = .....
    template.setFetchingDataRows(true);
    ...
    List res = this.dataContext.performQuery(template);
    Subject sub = (Subject)context.objectFromDataRow(Subject.class,
    (DataRow)res.get(0), true);

    Err:
    java.lang.NullPointerException at
    org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResol
    ver.java:117)
    at
    org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows
    (ObjectResolver.java:94)
    at
    org.apache.cayenne.access.DataContext.objectsFromDataRows(DataContext.ja
    va:597)
    at
    org.apache.cayenne.access.DataContext.objectFromDataRow(DataContext.java
    :646)
    ...........

    What, if anything am I doing incorrectly here? I have tried changing the
    refresh, and most of the other API calls with no success?

    Has this changed any in 3.0, as I see a few differences between the API
    and the docs?
    Andrus,

    We are running in the Felix OSGi container and are using a Java Proxy object
    (ObjectContext) to provide the context from a service, no
    serialization/deserialization.

    Since the proxy object disallows anything except the interface even a cast to
    DataContext is disallowed. In most cases the ObjectContext is all we want to
    provide, but in a few we need a DataContext to perform a little more magic.

    So, from the original we create a child ObjectContext which we can cast to
    DataContext so we can do some Cayenne magic.

    This is where the errors came in to play with ...objectFromDataRow().

    cheers,
    jeff
  • Andrus Adamchik at Oct 8, 2010 at 12:38 pm
    I confirmed - this is a bug with a nested context. Just opened a Jira:

    https://issues.apache.org/jira/browse/CAY-1489

    We'll work on fixing it.

    Andrus
    On Oct 7, 2010, at 7:01 PM, Jeff Rorison wrote:

    Andrus Adamchik <andrus <at> objectstyle.org> writes:
    Hi Jeff,

    From the lines in the stack trace, looks like
    context.getObjectStore().getDataRowCache() returns
    null, causing an NPE downstream. Now wondering why that can happen... Are you
    serializaing/deserializaing your DataContext?

    Andrus
    On Oct 6, 2010, at 9:04 PM, Rorison, Jeff wrote:

    I am using 3.0 (final) and am having some issues using
    context.createFromDataRow(...)

    ObjectResolver is throwing an NPE on what looks like updating snapshots.
    Code:

    SQLTemplate template = .....
    template.setFetchingDataRows(true);
    ...
    List res = this.dataContext.performQuery(template);
    Subject sub = (Subject)context.objectFromDataRow(Subject.class,
    (DataRow)res.get(0), true);

    Err:
    java.lang.NullPointerException at
    org.apache.cayenne.access.ObjectResolver.objectsFromDataRows(ObjectResol
    ver.java:117)
    at
    org.apache.cayenne.access.ObjectResolver.synchronizedObjectsFromDataRows
    (ObjectResolver.java:94)
    at
    org.apache.cayenne.access.DataContext.objectsFromDataRows(DataContext.ja
    va:597)
    at
    org.apache.cayenne.access.DataContext.objectFromDataRow(DataContext.java
    :646)
    ...........

    What, if anything am I doing incorrectly here? I have tried changing the
    refresh, and most of the other API calls with no success?

    Has this changed any in 3.0, as I see a few differences between the API
    and the docs?
    Andrus,

    We are running in the Felix OSGi container and are using a Java Proxy object
    (ObjectContext) to provide the context from a service, no
    serialization/deserialization.

    Since the proxy object disallows anything except the interface even a cast to
    DataContext is disallowed. In most cases the ObjectContext is all we want to
    provide, but in a few we need a DataContext to perform a little more magic.

    So, from the original we create a child ObjectContext which we can cast to
    DataContext so we can do some Cayenne magic.

    This is where the errors came in to play with ...objectFromDataRow().

    cheers,
    jeff


  • Jeff Rorison at Oct 8, 2010 at 5:07 pm

    Andrus Adamchik <andrus <at> objectstyle.org> writes:


    I confirmed - this is a bug with a nested context. Just opened a Jira:

    https://issues.apache.org/jira/browse/CAY-1489

    We'll work on fixing it.

    Andrus
    Outstanding, thanks for looking into it.

    cheers,
    jeff
  • Andrus Adamchik at Oct 21, 2010 at 6:15 pm
    Just committed the patch submitted by Andrei Veprev to 3.0.x branch and 3.1 (trunk). So this is fixed and will be available in the next release.

    Andrus


    On Oct 8, 2010, at 8:07 PM, Jeff Rorison wrote:

    Andrus Adamchik <andrus <at> objectstyle.org> writes:
    I confirmed - this is a bug with a nested context. Just opened a Jira:

    https://issues.apache.org/jira/browse/CAY-1489

    We'll work on fixing it.

    Andrus
    Outstanding, thanks for looking into it.

    cheers,
    jeff


Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedOct 6, '10 at 6:08p
activeOct 21, '10 at 6:15p
posts6
users2
websitecayenne.apache.org

2 users in discussion

Jeff Rorison: 3 posts Andrus Adamchik: 3 posts

People

Translate

site design / logo © 2021 Grokbase