java - Batch fetching returning null in JPA(Eclipse-Link) -
i have query batch fetch query being executed against 2 tables. these relations between them.
//category_on_page @entity @cacheable(true) @table(name="category_on_page") @jsonignoreproperties({"hibernatelazyinitializer", "handler", "fieldhandler"}) @entitylisteners({jpatoeofchangenotifier.class, jpaobjectchangesubscriber.class}) @was(com.stratahealth.shared.model.categoryonpage.class) public class categoryonformjpaimpl implements categoryonform { @notnull @manytoone(targetentity=categoryjpaimpl.class, fetch=fetchtype.lazy) @joincolumn(name="category_id") @org.eclipse.persistence.annotations.batchfetch(value=org.eclipse.persistence.annotations.batchfetchtype.join,size=990) private category category; } //category entity @entity @cacheable(true) @table(name="category") @entitylisteners({jpatoeofchangenotifier.class, jpaobjectchangesubscriber.class}) @jsonignoreproperties({"hibernatelazyinitializer", "handler", "fieldhandler"}) @jsonidentityinfo(generator=objectidgenerators.propertygenerator.class, property="id") @was(com.stratahealth.shared.model.category.class) public class categoryjpaimpl implements category { @onetomany(targetentity=categoryonformjpaimpl.class, mappedby="category") private set<categoryonform> categoryforms; the relationship on categorys on form. when batchfetch retrieves category page, null pointer thrown. stack trace.
javax.el.elexception: //usr/local/jsp/loader_194859196/meta-inf/resources/informationprofile.xhtml @28,59 listener="#{editinformationprofilecontroller.init()}": java.lang.nullpointerexception @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:111) @ com.sun.faces.facelets.tag.jsf.core.declarativesystemeventlistener.processevent(eventhandler.java:128) @ javax.faces.component.uicomponent$componentsystemeventlisteneradapter.processevent(uicomponent.java:2486) @ javax.faces.event.systemevent.processlistener(systemevent.java:106) @ com.sun.faces.application.applicationimpl.processlisteners(applicationimpl.java:2163) @ com.sun.faces.application.applicationimpl.invokecomponentlistenersfor(applicationimpl.java:2111) @ com.sun.faces.application.applicationimpl.publishevent(applicationimpl.java:289) @ com.sun.faces.application.applicationimpl.publishevent(applicationimpl.java:247) @ com.sun.faces.lifecycle.renderresponsephase.execute(renderresponsephase.java:107) @ com.sun.faces.lifecycle.phase.dophase(phase.java:101) @ com.sun.faces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:139) @ javax.faces.webapp.facesservlet.service(facesservlet.java:594) @ org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1550) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:343) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217) @ org.primefaces.webapp.filter.fileuploadfilter.dofilter(fileuploadfilter.java:100) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217) @ com.stratahealth.shared.common.filters.mainfilter.dofilter(mainfilter.java:30) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217) @ com.clickspace.csutilities.jsf.utf8characterencodingfilter.dofilter(utf8characterencodingfilter.java:15) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217) @ com.stratahealth.shared.common.filters.requireloginfilter.dofilter(requireloginfilter.java:63) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:256) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:217) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:279) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:175) @ org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:655) @ org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:595) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:161) @ org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:331) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:231) @ com.sun.enterprise.v3.services.impl.containermapper$adaptercallable.call(containermapper.java:317) @ com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:195) @ com.sun.grizzly.http.processortask.invokeadapter(processortask.java:860) @ com.sun.grizzly.http.processortask.doprocess(processortask.java:757) @ com.sun.grizzly.http.processortask.process(processortask.java:1056) @ com.sun.grizzly.http.defaultprotocolfilter.execute(defaultprotocolfilter.java:229) @ com.sun.grizzly.defaultprotocolchain.executeprotocolfilter(defaultprotocolchain.java:137) @ com.sun.grizzly.defaultprotocolchain.execute(defaultprotocolchain.java:104) @ com.sun.grizzly.defaultprotocolchain.execute(defaultprotocolchain.java:90) @ com.sun.grizzly.http.httpprotocolchain.execute(httpprotocolchain.java:79) @ com.sun.grizzly.protocolchaincontexttask.docall(protocolchaincontexttask.java:54) @ com.sun.grizzly.selectionkeycontexttask.call(selectionkeycontexttask.java:59) @ com.sun.grizzly.contexttask.run(contexttask.java:71) @ com.sun.grizzly.util.abstractthreadpool$worker.dowork(abstractthreadpool.java:532) @ com.sun.grizzly.util.abstractthreadpool$worker.run(abstractthreadpool.java:513) @ java.lang.thread.run(thread.java:662) caused by: java.lang.nullpointerexception @ org.eclipse.persistence.queries.readallquery.executeobjectlevelreadquery(readallquery.java:431) @ org.eclipse.persistence.queries.objectlevelreadquery.executedatabasequery(objectlevelreadquery.java:1168) @ org.eclipse.persistence.queries.databasequery.execute(databasequery.java:899) @ org.eclipse.persistence.queries.objectlevelreadquery.execute(objectlevelreadquery.java:1127) @ org.eclipse.persistence.queries.readallquery.execute(readallquery.java:403) @ org.eclipse.persistence.internal.sessions.abstractsession.internalexecutequery(abstractsession.java:3214) @ org.eclipse.persistence.internal.sessions.abstractsession.executequery(abstractsession.java:1804) @ org.eclipse.persistence.internal.sessions.abstractsession.executequery(abstractsession.java:1786) @ org.eclipse.persistence.mappings.onetoonemapping.executebatchquery(onetoonemapping.java:806) @ org.eclipse.persistence.mappings.foreignreferencemapping.extractresultfrombatchquery(foreignreferencemapping.java:643) @ org.eclipse.persistence.internal.indirection.batchvalueholder.instantiate(batchvalueholder.java:58) @ org.eclipse.persistence.internal.indirection.querybasedvalueholder.instantiate(querybasedvalueholder.java:116) @ org.eclipse.persistence.internal.indirection.databasevalueholder.getvalue(databasevalueholder.java:89) @ org.eclipse.persistence.internal.indirection.unitofworkvalueholder.instantiateimpl(unitofworkvalueholder.java:173) @ org.eclipse.persistence.internal.indirection.unitofworkvalueholder.instantiate(unitofworkvalueholder.java:234) @ org.eclipse.persistence.internal.indirection.databasevalueholder.getvalue(databasevalueholder.java:89) @ com.stratahealth.shared.model.restimpl.jpa.categoryonformjpaimpl._persistence_get_category(categoryonformjpaimpl.java) @ com.stratahealth.shared.model.restimpl.jpa.categoryonformjpaimpl.getcategory(categoryonformjpaimpl.java:60) @ com.stratahealth.shared.common.services.impl.categoryserviceimpl.sortedcategoriesforformwithcaretypes(categoryserviceimpl.java:104) @ com.stratahealth.shared.common.controllers.editinformationprofilecontroller.getcategoriesonformforcaretype(editinformationprofilecontroller.java:1421) @ com.stratahealth.shared.common.controllers.editinformationprofilecontroller.init(editinformationprofilecontroller.java:442) @ sun.reflect.generatedmethodaccessor1206.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ javax.el.beanelresolver.invokemethod(beanelresolver.java:779) @ javax.el.beanelresolver.invoke(beanelresolver.java:528) @ javax.el.compositeelresolver.invoke(compositeelresolver.java:257) @ com.sun.el.parser.astvalue.invoke(astvalue.java:248) @ com.sun.el.methodexpressionimpl.invoke(methodexpressionimpl.java:302) @ com.sun.faces.facelets.el.tagmethodexpression.invoke(tagmethodexpression.java:105) ... 49 more inside readallquery.executeobjectlevelreadquery method, null pointer being thrown. because "translationrow" being rendered null. not consistent, have been able reproduce luck.
the line npe is:
object sopobject = gettranslationrow().getsopobject(); when gettranslationrow() called, null value return , exception thrown. method npe happening inside eclipse link library.
/** * internal: * execute query. * rows , build object rows. * @exception databaseexception - error has occurred on database * @return java.lang.object collection of objects resulting execution of query. */ @override protected object executeobjectlevelreadquery() throws databaseexception { object result = null; if (this.containerpolicy.overridesread()) { this.executiontime = system.currenttimemillis(); return this.containerpolicy.execute(); } if (this.descriptor.isdescriptorforinterface()) { object returnvalue = this.descriptor.getinterfacepolicy().selectallobjectsusingmultipletablesubclassread(this); this.executiontime = system.currenttimemillis(); return returnvalue; } if (this.descriptor.hastableperclasspolicy() && this.descriptor.isabstract()) { result = this.containerpolicy.containerinstance(); } else { object sopobject = gettranslationrow().getsopobject(); boolean useoptimization = false; if (sopobject == null) { useoptimization = usesresultsetaccessoptimization(); } if (useoptimization) { databasecall call = ((datasourcecallquerymechanism)this.querymechanism).selectresultset(); this.executiontime = system.currenttimemillis(); statement statement = call.getstatement(); resultset resultset = call.getresult(); databaseaccessor dbaccessor = (databaseaccessor)getaccessor(); boolean exceptionoccured = false; try { if (this.session.isunitofwork()) { result = registerresultsetinunitofwork(resultset, call.getfields(), call.getfieldsarray(), (unitofworkimpl)this.session, this.translationrow); } else { result = this.containerpolicy.containerinstance(); this.descriptor.getobjectbuilder().buildobjectsfromresultsetinto(this, resultset, call.getfields(), call.getfieldsarray(), result); } } catch (sqlexception exception) { exceptionoccured = true; databaseexception commexception = dbaccessor.processexceptionforcommerror(this.session, exception, call); if (commexception != null) { throw commexception; } throw databaseexception.sqlexception(exception, call, dbaccessor, this.session, false); } { try { if (resultset != null) { resultset.close(); } if (dbaccessor != null) { if (statement != null) { dbaccessor.releasestatement(statement, call.getsqlstring(), call, this.session); } } if (call.hasallocatedconnection()) { getexecutionsession().releaseconnectionaftercall(this); } } catch (runtimeexception cleanupexception) { if (!exceptionoccured) { throw cleanupexception; } } catch (sqlexception cleanupsqlexception) { if (!exceptionoccured) { throw databaseexception.sqlexception(cleanupsqlexception, call, dbaccessor, this.session, false); } } } } else { list<abstractrecord> rows; if (sopobject != null) { object valuesiterator = this.containerpolicy.iteratorfor(gettranslationrow().getsopobject()); int size = this.containerpolicy.sizefor(sopobject); rows = new arraylist<abstractrecord>(size); while (this.containerpolicy.hasnext(valuesiterator)) { object membersopobject = this.containerpolicy.next(valuesiterator, this.session); databaserecord memberrow = new databaserecord(0); memberrow.setsopobject(membersopobject); rows.add(memberrow); } this.executiontime = system.currenttimemillis(); } else { rows = getquerymechanism().selectallrows(); this.executiontime = system.currenttimemillis(); // if using 1-m joins, must set rows. if (hasjoining() && this.joinedattributemanager.istomanyjoin()) { this.joinedattributemanager.setdataresults(rows, this.session); } // batch fetching in in requires access rows build id array. if ((this.batchfetchpolicy != null) && this.batchfetchpolicy.isin()) { this.batchfetchpolicy.setdataresults(rows); } } if (this.session.isunitofwork()) { result = registerresultinunitofwork(rows, (unitofworkimpl)this.session, this.translationrow, true);// } else { if (rows instanceof threadcursoredlist) { result = this.containerpolicy.containerinstance(); } else { result = this.containerpolicy.containerinstance(rows.size()); } this.descriptor.getobjectbuilder().buildobjectsinto(this, rows, result); } if (sopobject != null) { if (!this.descriptor.getobjectbuilder().issimple()) { // remove sopobject it's not stuck in value holder. (abstractrecord row : rows) { row.setsopobject(null); } } } else { if (this.shouldincludedata) { complexqueryresult complexresult = new complexqueryresult(); complexresult.setresult(result); complexresult.setdata(rows); result = complexresult; } } } } // add other (already registered) results , return them. if (this.descriptor.hastableperclasspolicy()) { result = this.containerpolicy.concatenatecontainers( result, this.descriptor.gettableperclasspolicy().selectallobjectsusingmultipletablesubclassread(this), this.session); } // if results empty, ensure cached still. if (shouldcachequeryresults() && this.containerpolicy.isempty(result)) { this.temporarycachedqueryresults = invalidobject.instance(); } return result; } from limited understanding of eclipse link.i believe translation row row retrieved batch fetch query. have ideas why being rendered null.....any appreciated.
Comments
Post a Comment