DataContext should be created via DataContext.createDataContext() if you're using shared configuration (cayenne.xml in classpath). Although there could be changes in 3.1 shapshot - I think Andrus iы reworking something there. Also the simplest way to get DataObject for PK is Cayenne.objectForPk(...) in 3.1 and DataObjectUtils.objectForPk(...) in 3.0
2010/2/7 Andrew Lindesay <[email protected]> > Hello; > > I am using 3.1 snapshot and am trying to do this in order to get an > DataObject instance for the ObjectId which I have; > > DataContext dc = new DataContext(); > ObjectId xyzObjectId = xyzObjectIds.get(i); > XYZ xyz = (XYZ) dc.performQuery(new > ObjectIdQuery(xyzObjectId)).get(0); > > I get an NPE here; > > > > org.apache.cayenne.util.ObjectContextQueryAction.runQuery(ObjectContextQueryAction.java:335) > at > org.apache.cayenne.util.ObjectContextQueryAction.execute(ObjectContextQueryAction.java:96) > at > org.apache.cayenne.access.DataContext.onQuery(DataContext.java:1049) at > > org.apache.cayenne.access.DataContext.performQuery(DataContext.java:1038) > > Which is this in code; > > protected void runQuery() > { this.response = actingContext.getChannel().onQuery(actingContext, > query); } > > The problem is that there is no channel on the context. > > Am I using the API correctly? > > Regards; > > ___ > Andrew Lindesay > www.lindesay.co.nz > > -- Andrey
