Named Query Error

Hi,
I'm having trouble passing argument to a named query in the mapping workbench.
Here is my SQL:
SELECT COUNT(*) FROM VALID_PARTY_CLASSIF, CLASSIF_TYPE WHERE CLASSIF_TYPE.CLASSIF_TYPE_ID = VALID_PARTY_CLASSIF.CLASSIF_TYPE_ID AND CLASSIF_TYPE.CLASSIF_TYPE_ID = #ID
and when I find and execute the query, getting following error
Execute query ReadObjectQuery(com.amgen.bria.business.bizobject.ClassificationTypeBO)
SELECT COUNT(*) FROM VALID_PARTY_CLASSIF, CLASSIF_TYPE WHERE CLASSIF_TYPE.CLASSIF_TYPE_ID = VALID_PARTY_CLASSIF.CLASSIF_TYPE_ID AND CLASSIF_TYPE.CLASSIF_TYPE_ID = ?
     bind => [56]
Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4) (Build 031018)): oracle.toplink.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRow(
     => 0)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadObjectQuery(com.amgen.bria.business.bizobject.ClassificationTypeBO)Local Exception Stack:
Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4) (Build 031018)): oracle.toplink.exceptions.QueryException
Exception Description: The primary key read from the row [DatabaseRow(
     => 0)] during the execution of the query was detected to be null. Primary keys must not contain null.
Query: ReadObjectQuery(com.amgen.bria.business.bizobject.ClassificationTypeBO)
     at oracle.toplink.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:541)
     at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:262)
     at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:226)
     at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:344)
     at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:498)
     at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
     at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1968)
     at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
     at oracle.toplink.threetier.ClientSession.internalExecuteQuery(ClientSession.java:392)
     at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1096)
     at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1065)
     at oracle.toplink.publicinterface.Session.executeQuery(Session.java:966)
     at com.amgen.bria.persistence.module.toplink.TopLinkPersistenceService.internalExecuteQuery(TopLinkPersistenceService.java:137)
     at com.amgen.bria.persistence.PersistenceService.executeQuery(PersistenceService.java:97)
     at com.amgen.cma.persistence.service.ClassificationPersistenceService.findCustomerForClassifTypeCount(ClassificationPersistenceService.java:405)
     at com.amgen.cma.persistence.service.ClassificationPersistenceServiceTest.testFindCustomerForClassifTypeCount(ClassificationPersistenceServiceTest.java:193)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at junit.framework.TestCase.runTest(TestCase.java:154)
     at junit.framework.TestCase.runBare(TestCase.java:127)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:118)
     at junit.framework.TestSuite.runTest(TestSuite.java:208)
     at junit.framework.TestSuite.run(TestSuite.java:203)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
client released
Please let me know if I am missing anything.
Thanks
Saket

Saket, the problem is right here:
ReadObjectQuery(com.amgen.bria.business.bizobject.Clas
ificationTypeBO)
When you read a an object mapping back, the primary key you have specified for that object mapping in Toplink has to be part of this search criteria (it is how it's stored in toplink's identity map/cache)
Since you are only executing a 'select count(*)', it is erroring out
HTH,
Sean

Similar Messages

  • Mysql w/ JDeveloper EJB Named Query Error

    I have the following named query:
    @NamedQuery(name = "Node.topParent", query = "select o from Node o where o.node is null")
    However, when converted to a SQL query (connected to MySQL) it shows:
    select * from "node" where (parentId IS NULL)
    The "node" causes MySQL to error however if I manually remove them then it works. Why is the query using "" and how can I configure it to by MySQL compliant?
    Thanks in advance,
    Kris

    Appears that by default JDeveloper uses \" in the annotations for table name.

  • AVG calculation and syntax error while parsing a named query

    Hi all,
    I've to calcolate the average of polling results for each value column (5 value column in total). I want to use this single row result line for a bar graph.
    I created a new named query in the EJB:
    @NamedQueries({
      @NamedQuery(name = "Polls.findAll", query = "select o from Polls o"),
      @NamedQuery(name = "Polls.findAVG", query = "select o AVG(Value1) as Value1, AVG(Value2)  as Value2, AVG(Value3)  as Value3, AVG(Value4)  as Value4, AVG(Value5)  as Value5 o from Polls o")   // <-- my named query
    ...I tried it in the sql query tool of Oracle 10g XE and sql syntax is ok, but when I run my javaServiceFacade on JDev I receive this message:
    Exception in thread "main" Local Exception Stack:
    Exception [EclipseLink-8023] (Eclipse Persistence Services - 1.0.1 (Build 20080905)): org.eclipse.persistence.exceptions.JPQLException
    Exception Description: Syntax error parsing the query [Polls.findAVG: select AVG(Value1) as Value1, AVG(Value2)  as Value2, AVG(Value3) as Value3, AVG(Value4) as Value4, AVG(Value5) as Value5 o from Polls o].
    Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
    ...Where is the syntax error in my named query?
    Edited by: Silicio on 22-nov-2008 1.05

    Thanks Shay, now I think syntax is correct for gain an average for each column:
    @NamedQuery(name = "Polls.findAVG", query = "select AVG(o.value1), AVG(o.value2), AVG(o.value3), AVG(o.value4), AVG(o.value5) from Polls o")But still got some trouble to get a bar graph...
    If I drag&drop that query from data control, I get an empty graph with 5 values ,look http://img153.imageshack.us/img153/8710/emptygraphag7.png .
    In the log there is some errors (due that named query and its methods in EJB):
    AVVERTENZA: Transient state added to StateManager.  State may not be serialized.  State id:  data.oracle_view_risultatiPageDef.Polls1__cubicDefinition
    23-nov-2008 11.08.28 oracle.adf.share.http.HttpSessionStateManagerImpl putState
    AVVERTENZA: Transient state added to StateManager.  State may not be serialized.  State id:  data.oracle_view_risultatiPageDef.Polls1__dataModel
    [EL Info]: 2008.11.23 11:08:29.546--ServerSession(20936795)--EclipseLink, version: Eclipse Persistence Services - 1.0.1 (Build 20080905)
    [EL Info]: 2008.11.23 11:08:29.562--ServerSession(20936795)--Server: WebLogic Server Temporary Patch for CR380042 Thu Sep 11 13:33:40 PDT 2008
    [EL Info]: 2008.11.23 11:08:29.562--ServerSession(20936795)--file:/C:/Oracle/Middleware/jdeveloper/system/system11.1.1.0.31.51.56/o.j2ee/drs/Application13/Application13-Model-ejb/-Model login successful
    23-nov-2008 11.08.37 oracle.adfinternal.view.faces.config.rich.RegistrationConfigurator handleError
    GRAVE: Server Exception during PPR, #1
    oracle.jbo.JboException: JBO-29000: Unexpected exception caught: groovy.lang.MissingPropertyException, msg=Exception evaluating property 'id' for java.util.Arrays$ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: id for class: java.lang.Double
         at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:753)
         at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:779)
         at oracle.jbo.ExprEval.evaluateForRow(ExprEval.java:690)
         at oracle.jbo.server.AttributeDefImpl.evaluateTransientExpression(AttributeDefImpl.java:1816)
         at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1554)
         at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1634)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:746)
         at oracle.adf.model.bean.DCDataRow.getAttributeInternal(DCDataRow.java:352)
         at oracle.jbo.server.ViewRowImpl.getKey(ViewRowImpl.java:598)
         at oracle.adf.model.bean.DCDataRow.getKey(DCDataRow.java:149)
         at oracle.adf.model.binding.DCIteratorBinding.buildFormToken(DCIteratorBinding.java:3836)
         at oracle.adf.model.binding.DCBindingContainerState.buildStringBuffer(DCBindingContainerState.java:71)
         at oracle.adf.model.binding.DCBindingContainerState.toString(DCBindingContainerState.java:590)
         at oracle.adf.model.binding.DCBindingContainer.getStateToken(DCBindingContainer.java:4293)
         at oracle.adfinternal.controller.application.model.SaveStateTokenListener.afterPhase(SaveStateTokenListener.java:54)
         at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.afterPhase(ADFLifecycleImpl.java:529)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchAfterEvent(LifecycleImpl.java:118)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchAfterPagePhaseEvent(LifecycleImpl.java:166)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchAfterPagePhaseEvent(ADFPhaseListener.java:122)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:68)
         at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:51)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:203)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:278)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:238)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:195)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:138)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:102)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by: groovy.lang.MissingPropertyException: Exception evaluating property 'id' for java.util.Arrays$ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: id for class: java.lang.Double
         at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:2978)
         at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1368)
         at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2578)
         at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:178)
         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:474)
         at Script1.run(Script1.groovy)
         at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:741)
         ... 50 more
    ## Detail 0 ##
    groovy.lang.MissingPropertyException: Exception evaluating property 'id' for java.util.Arrays$ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: id for class: java.lang.Double
         at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:2978)
         at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:1368)
         at groovy.lang.MetaClassImpl.getProperty(MetaClassImpl.java:2578)
         at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:178)
         at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:474)
         at Script1.run(Script1.groovy)
         at oracle.jbo.ExprEval.internalEvaluateGroovyScript(ExprEval.java:741)
         at oracle.jbo.ExprEval.doEvaluate(ExprEval.java:779)
         at oracle.jbo.ExprEval.evaluateForRow(ExprEval.java:690)
         at oracle.jbo.server.AttributeDefImpl.evaluateTransientExpression(AttributeDefImpl.java:1816)
         at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1554)
         at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1634)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:746)
         at oracle.adf.model.bean.DCDataRow.getAttributeInternal(DCDataRow.java:352)
         at oracle.jbo.server.ViewRowImpl.getKey(ViewRowImpl.java:598)
         at oracle.adf.model.bean.DCDataRow.getKey(DCDataRow.java:149)
         at oracle.adf.model.binding.DCIteratorBinding.buildFormToken(DCIteratorBinding.java:3836)
         at oracle.adf.model.binding.DCBindingContainerState.buildStringBuffer(DCBindingContainerState.java:71)
         at oracle.adf.model.binding.DCBindingContainerState.toString(DCBindingContainerState.java:590)
         at oracle.adf.model.binding.DCBindingContainer.getStateToken(DCBindingContainer.java:4293)
         at oracle.adfinternal.controller.application.model.SaveStateTokenListener.afterPhase(SaveStateTokenListener.java:54)
         at oracle.adfinternal.controller.lifecycle.ADFLifecycleImpl$PagePhaseListenerWrapper.afterPhase(ADFLifecycleImpl.java:529)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.internalDispatchAfterEvent(LifecycleImpl.java:118)
         at oracle.adfinternal.controller.lifecycle.LifecycleImpl.dispatchAfterPagePhaseEvent(LifecycleImpl.java:166)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.dispatchAfterPagePhaseEvent(ADFPhaseListener.java:122)
         at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:68)
         at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:51)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:203)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:181)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:278)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:238)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:195)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:138)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:102)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3496)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2180)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2086)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1406)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)I try to print out a singlue AVG value in this way (main method of javaServerFacade class):
        public static void main(String [] args) {
            final JavaServiceFacade javaServiceFacade = new JavaServiceFacade();
            //  TODO:  Call methods on javaServiceFacade here...
            List<Polls> pollsAVG = javaServiceFacade.queryPollsFindAVG();
            for (Polls a: pollsAVG){
                System.out.println(a.getValue1());
    ...I get this error:
    Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to oracle.model.Polls
         at oracle.model.JavaServiceFacade.main(JavaServiceFacade.java:25)
    Process exited with exit code 1.
    ...I've searched for Ljava in the documantation finding nothing interesting.

  • Derby db named query causes parse error when using derby db MONTH function

    Hi all!
    I'm trying to create an application using the persistance api and beans binding. I have created my database and entity classes.
    My problem is creating a named query that uses some of the functionality from the derby database (which is embedded in the application).
    I have a named query:
    @NamedQuery(name = "Vehicles.findbymotmonth", query = "SELECT v FROM Vehicles v WHERE MONTH(v.lastmotdate) = :monthnumber") The actual query works fine when I send it directly to the db (with the parameter filled in) but causes an exception when used as a named query:
    Local Exception Stack:
    Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Syntax error parsing the query [Vehicles.findbymotmonth: SELECT v FROM Vehicles v WHERE MONTH(v.lastmotdate) = :monthnumber], line 1, column 32: unexpected token [MONTH].
    Internal Exception: line 1:32: unexpected token: MONTH
            at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389)
    ... I've tried looking for solutions online but it seems evryone just writes up the original java db application example provided by sun and no one has tried doing more than "select c from customers c".
    I'm using the netbeans ide (6.5).
    Please tell me there is a simple solution to this and the persistance API can handle complex queries!
    Thanks in advance.

    one solution: assume the toplink library to be so full of bugs as to be unusable and switch to the hibernate persistance manager where it works fine.
    Edited by: pointer2null on Feb 17, 2009 11:02 AM

  • Error when use stored procedure in Named Query and Custom SQL

    This is a toplink development on Jdev 1013. A package with a function is created which returns a "ref cursor" in a oracle 9i database. I tried to access the function in jdev toplink descriptor editor either through custom sql (Readall) or a named query (procedureTest) and I got java.sql.SQLException: SQL string is not Query. Note: I am NOT talking about programatic storedprocedurecall object.
    The client access code is following (where error was thrown):
    results = (Collection) session.executeQuery("procedureTest", WuTest.class);

    Any responses? Thanks.

  • Named query problem, [TOPLINK-6008] error

    I created a simple table in database (one column, two rows). I created java class and Data Control and dragged the Data Control onto JSP page. Data were shown ok. Then I tried to create named query (simple SELECT MyCol FROM FROM MyTable). This time the new Data Control on JSP didn't work (no data shown). So I tried this scriptlet on jsp:
    <%
    String sDC = "MyDataControl";
    DCDataControl dc = HttpBindingContext.getContext(request).findDataControl(sDC);
    ClientSession cs = ((ToplinkDataControl)dc).getClientSession();
    Vector all = (Vector)cs.executeQuery("MyNamedQuery",mypackage.MyTable.class);
    %>
    Last row causes error
    Exception [TOPLINK-6008] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.QueryException
    Description: Missing descriptor for [mypackage.MyTable] for query named [MyNamedQuery].
         at oracle.toplink.exceptions.QueryException.descriptorIsMissingForNamedQuery(QueryException.java:282)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:878)
         at dataPage.jspService(dataPage.jsp:26)
    Does anybody have an idea why the jsp page with Data Control based on named query is empty and why above scriptlet causes that error ? Thanks.

    This solution only applies to earlier version of JDeveloper. In 10.1.3 the TopLink metadata (XML deployment descriptor) is automatically generated during the build/make process as required. In earlier version this is a required step after any change is made to the mappings .
    Doug

  • ERROR: Cannot create authcontext with null org-Naming query failed  code:21

    I use OpenSSO Enterprise 8.0 Update 1 Patch1 Build 6.1(2009-June-9 12:56)
    I try to evaluate the Apache 2.2 web agent.
    It's been installed without errors, and both the OpenSSO and Apache server restarted.
    The agent profile's been created. Also, I use the default (OpenDS) configuration repository
    for OpenSSO, but an external (DSEE) user data directory.
    I think I did all the required steps with regards to both directories, since I don't see any error
    in the LDAP logs, each entry seems to be found as expected, the BIND operations are all
    successfull.
    Also, I use a sub-realm rather than the default top realm, and thus, I've modified the agent configuration
    (in the agent profile) so that the login URL is now ... /UI/Login?realm=myrealm
    When I try to access the Apache homepage, I get an error 500. The most recent OpenSSO server log file
    (...../opensso/debug/Authentication) contains the following message:
    ERROR: Cannot create authcontext with null org
    The most recent agent log file (....../apache22_agent/Agent_001/logs/debug/amAgent) has the following error:
    2009-07-07 17:08:11.992 Error 10513:80149a50 PolicyEngine: am_policy_evaluate: InternalException in Service::update_policy with error message:Naming query failed. and code:21
    I don't know what else I can do to debug this problem and find a solution. Any idea ?

    Thank you Shubba,
    With all available log details enabled, I now have the following messages on the agent side:
    2009-07-09 10:14:51.731MaxDebug 5613:80149a50 all: No value specified for key com.sun.identity.agents.config.profile.attribute.mapping, using default value .
    2009-07-09 10:14:51.731 Debug 5613:80149a50 NamingService: BaseService::doRequest(): Using server: http://portable.antibes.net:8080/opensso/namingservice.
    2009-07-09 10:14:51.731MaxDebug 5613:80149a50 NamingService:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <RequestSet vers="1.0" svcid="com.iplanet.am.naming" reqid="10">
    <Request><![CDATA[                                                                                                                      
      <NamingRequest vers="3.0" reqid="2" sessid=""AQIC5wM2LY4SfcyaGFgc5h9Y7/kpf4f//ml82oVfNlbWxQE=@AAJTSQACMDE=#"">                             <GetNamingProfile>                                                                                                                         </GetNamingProfile>                                                                                                                        </NamingRequest>]]> </Request>
    </RequestSet>
    2009-07-09 10:14:51.712MaxDebug 5613:80149a50 NamingService: BaseService::sendRequest Request line: POST /opensso/namingservice HTTP/1.0
    2009-07-09 10:14:51.712 Debug 5613:80149a50 NamingService: BaseService::sendRequest Cookie and Headers =Host: portable.antibes.net
    2009-07-09 10:14:51.712 Debug 5613:80149a50 NamingService: BaseService::sendRequest Content-Length =Content-Length: 334
    2009-07-09 10:14:51.712 Debug 5613:80149a50 NamingService: BaseService::sendRequest Header Suffix =Accept: text/xml
    Content-Type: text/xml; charset=UTF-8
    2009-07-09 10:14:51.712MaxDebug 5613:80149a50 NamingService: BaseService::sendRequest(): Total chunks: 7.
    2009-07-09 10:14:51.712MaxDebug 5613:80149a50 NamingService: BaseService::sendRequest(): Sent 7 chunks.
    2009-07-09 10:14:51.728 Debug 5613:80149a50 NamingService: HTTP Status = 500 (Internal Server Error)
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Http::Response::readAndParse(): Reading headers.
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Server: Apache-Coyote/1.1
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Content-Type: text/html;charset=utf-8
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Date: Thu, 09 Jul 2009 08:14:51 GMT
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Connection: close
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Http::Response::readAndParse(): Reading body content of length: 13830487939496281954
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 all: Connection::waitForReply(): returns with status success.
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: Http::Response::readAndParse(): Completed processing the response with status: success
    2009-07-09 10:14:51.729MaxDebug 5613:80149a50 NamingService: <html><head><title>Apache Tomcat/6.0.18 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>javax.servlet.ServletException: AMSetupFilter.doFilter
    com.sun.identity.setup.AMSetupFilter.doFilter(AMSetupFilter.java:117)
    </pre></p><p><b>root cause</b> <pre>java.lang.NullPointerException
    com.iplanet.services.naming.service.NamingService.processRequest(NamingService.java:361)
    com.iplanet.services.naming.service.NamingService.process(NamingService.java:352)
    com.iplanet.services.comm.server.PLLRequestServlet.handleRequest(PLLRequestServlet.java:180)
    com.iplanet.services.comm.server.PLLRequestServlet.doPost(PLLRequestServlet.java:134)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.identity.setup.AMSetupFilter.doFilter(AMSetupFilter.java:91)
    </pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.18</h3></body></html>
    2009-07-09 10:14:51.729 Warning 5613:80149a50 NamingService: BaseService::doHttpPost() failed, HTTP error = 500
    2009-07-09 10:14:51.729 Debug 5613:80149a50 NamingService: NamingService()::getProfile() returning with error code HTTP error.
    2009-07-09 10:14:51.729 Error 5613:80149a50 PolicyEngine: am_policy_evaluate: InternalException in Service::update_policy with error message:Naming query failed. and code:21
    In my Tomcat server (OpenSSO server web container), I have the following errors:
    Jul 9, 2009 10:12:35 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 22746 ms
    [Fatal Error] :2:46: Element type "NamingRequest" must be followed by either attribute specifications, ">" or "/>".
    java.lang.NullPointerException
    at com.iplanet.services.naming.service.NamingService.processRequest(NamingService.java:361)
    at com.iplanet.services.naming.service.NamingService.process(NamingService.java:352)
    at com.iplanet.services.comm.server.PLLRequestServlet.handleRequest(PLLRequestServlet.java:180)
    at ...
    It seems like the problem comes from the couple of closing square brackets in the NamingRequest tag:
    </NamingRequest>]]>
    I don't know where it comes from, so if you've an idea I'd enjoy .
    Cheers,

  • How to create olap cube using Named Query Table in Data source View

     I Create on OLAP Cube using Existing Tables Its Working Fine But When i Use Named Query Table with RelationShip To other Named query Table  It Not Working .So give me some deep Clarification On Olap Cube for Better Understanding
    Thanks

    Hi Pawan,
    What do you mean "It Not Working"? As Kamath said, please post the detail error message, so that we can make further analysis.
    In the Data Source View of a CUBE, we can define a named query. In a named query, you can specify an SQL expression to select rows and columns returned from one or more tables in one or more data sources. A named query is like any other table in a data source
    view (DSV) with rows and relationships, except that the named query is based on an expression.
    Reference:Define Named Queries in a Data Source View (Analysis Services)
    Regards,
    Charlie Liao
    TechNet Community Support

  • Wrong parameter substitution in named query

    We are on TopLink 10.1.3
    We have a named query – ‘Select * from table where userid = #userid and status = #status’
    This query executes correctly most of the times, but intermittently it will substitute the first parameter’s(id) value for both id and status parameters.
    There is nothing consistent about it, just seems to randomly happens and that too only on PROD.
    There are no errors, but the data retrieved is wrong.
    When the query is executed correctly we get
    SELECT * FROM table WHERE ((userid_C = ‘user1’) AND (status = ‘N’))
    But when it does not this is what the log shows -
    SELECT * FROM table WHERE ((userid_C = ‘user1’) AND (status = ‘user1’))
    Can someone please throw some light on this weird behavior?
    Thanks.

    Odd, I have never heard of this before.
    Try narrowing down when it occurs, and try to recreate in a test case.
    Check that your own code is thread safe, and is passing the correct parameters to the query. Include your code for the query execution.

  • Named query question

    Hi Guys,
    I have the following problem - I know I did something wrong, but I cannot figure out how to correct it. Here is my question:
    I have a table tableA, with composite key (col1, col2, col3, col4). I mapped the table, and create a Toplink named query (findCol3List)as such:
    select distinct col3
    from tableA
    where col1=#col1 and col2=#col2
    I created an EJB session method getCol3List(col1, col2) -
    now when I run the application to call this EJB method, I got the following error at line:
    List results = (List)session.executeQuery("findCol3List", String.class, params);
    Exception Description: Missing descriptor for [java.lang.String] for query named [findCol3List].
    I know there are multiple mistakes in my approach, but with my limited Toklink knowledge, I could not figure out.
    Any help with be appreciated!

    hello,
    The executeQuery method is trying to look up the "findCol3List" in the descriptor for the class passed in. It is complaining because you passed in String.class which does not have a valid descriptor.
    How/where did you define the named query? Chances are you defined it in the class used for TableA, and so should specify it in the executeQuery method:
    session.executeQuery("findCol3List", tableA.class, params);
    Best Regards,
    Chris

  • Named query gives a null argument exception in JPQL

    Hi all,
    I need your help with a named query which i have which returns a org.apache.openjpa.persistence.ArgumentException: null .
    Here is my named query:
    @NamedQuery(name="user_deactivateUser", query="update UserImpl u SET u.bisdeleted=1,u.dtupdatedate=SYSDATE, u.dtdeletedate=SYSDATE where u.nID=?1" Now when i call this query in my method it gives an null pointer exception at q.executeUpdate().
    public void doDeactivateAllUsers(int userID) throws ServiceException{
      EntityManager em = null;
      em = BaseDAO.getEntityManager();
      Query q = em.createNamedQuery("user_deactivateUser");
                   q.setParameter(1,userID);
                   int count = q.executeUpdate();here is the full stack trace of this exception.
    <openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: null
         at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:814)
         at org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:884)
         at org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:573)
         at org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:336)
         at com.forrester.companyadmin.service.DeactivateUserService.doDeactivateUser(DeactivateUserService.java:98)
         at com.forrester.companyadmin.service.DeactivateUserService.doDeactivateAllUsers(DeactivateUserService.java:225)
         at com.forrester.companyadmin.controller.DeactivateUsersController.action(DeactivateUsersController.java:376)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
         at javax.faces.component.UICommand.broadcast(UICommand.java:325)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:287)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:401)
         at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
         at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at com.forrester.companyadmin.filters.CompanyAdminFilter.doFilter(CompanyAdminFilter.java:102)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
         at java.lang.Thread.run(Unknown Source).
    Can someone let me know if there is anything wrong in the way iam passing these parameteres
    Edited by: user8769643 on Mar 19, 2010 7:37 AM

    i got this working. I am passing dtupdate=SYSDATE which is incorrect. i added one more parameter "q.setParameter(3,new java.util.Date())" to pass today's date and it worked.
    Thanks

  • Named Query (JOIN query) runs in Toplink JPA but not in EclipseLink

    I have a namedquery in JPA entities like (Entities do not include JOIN colums specifically.. no many-to-many or one-to-many relation in entities)
    select a from table1 a, table2 b where a.id=b.id
    This named query runs on Toplink Essentials without any problem.
    When I run this query using EclipseLink
    EclipseLink generates the query below and gives an error.
    select table1.id, table1.name, table1.surname from table1 t0, table2 t1 where t0.id=t1.id
    There are error _"*table1.surname*"_ is invalid identifier. Because; table1 is not define as an alias, must be "t0.surname".
    How can I solce this problem.
    The code runs on Toplink Essential but not in EclipseLink

    I have a namedquery in JPA entities like (Entities do not include JOIN colums specifically.. no many-to-many or one-to-many relation in entities)
    select a from table1 a, table2 b where a.id=b.id
    This named query runs on Toplink Essentials without any problem.
    When I run this query using EclipseLink
    EclipseLink generates the query below and gives an error.
    select table1.id, table1.name, table1.surname from table1 t0, table2 t1 where t0.id=t1.id
    There are error _"*table1.surname*"_ is invalid identifier. Because; table1 is not define as an alias, must be "t0.surname".
    How can I solce this problem.
    The code runs on Toplink Essential but not in EclipseLink

  • IllegalArgumentException when using Constructor expression in Named Query.

    I have the following JPQL-query:
    SELECT NEW se.callista.test.dto.EmployeeReportData(e.firstName, e.lastName, a.city, e.employmentPeriod.startDate) FROM Employee e JOIN e.address a ORDER BY e.lastName, e.firstNamewhere EmployeeReportData is a dto (not an entity). The query works fine when running it as a normal query. When I put it as a named query however, I get the following error message when trying to execute it: java.lang.IllegalArgumentException: Object: se.callista.test.dto.EmployeeReportData@10f9644 is not a known entity type.
    I can't find anything in the JPA-spec that says a named query cannot contain a constructor expression - am I missing something?
    Found the error. It works fine now :)
    Message was edited by:
    Sofia_Jonsson

    I had the same problem.
    It seems that the Entity class is not loaded by the JVM at the moment of calling createNamedQuerey(string).
    I've solved this problem by loading the entity class manually in the caller by calling "Class.forName(string)" and passing the entity's class name as a parameter.

  • [JPA] SELECT NEW inside SELECT NEW in Named Query

    Suppose i have two JPA entities Master and Detail as follows:
    @Entity
    public class Master implements Serializable{
        private static final long serialVersionUID = 1L;
        private long id;
        private String masterField1;
        private String masterField2;
        private String masterField3;
         private String masterField4;
        private String masterField5;   
        //A lot of other fields till masterFieldn...
        private String masterFieldn;
        private List<Detail> detailList;
        //getters and setters here...
        @OneToMany(mappedBy = "master", cascade = { CascadeType.ALL }, fetch=FetchType.EAGER)
        @OrderBy("detailField1 DESC")
        public List<Detail> getDetailList() {
            return detailList;
    @Entity
    public class Detail implements Serializable{
        private static final long serialVersionUID = 1L;
        private long id;
        private String detailField1;
        private String detailField2;
        private String detailField3;
         private String detailField4;
        private String detailField5;   
        //A lot of other fields till detailFieldn...
        private String detailFieldn;
        private Master master;
        //getters and setters here...
        @ManyToOne
        @JoinColumn(name="MASTER_ID", referencedColumnName="ID")    public Master getMaster() {
            return master;
        }Both Master and Detail entities have a lot of fields, but i only need a subset of those fields when these entities are queried. So, i have two helper classes which i use in named queries in Master JPA entity :
    @NamedQueries({
            @NamedQuery(name = "Master.findMaster",
                query = "SELECT NEW MasterHelper(" +
                    "t.masterField1, t.masterField2, t.masterField3, " +
                    " SELECT NEW DetailHelper(" +
                    "td.detailField1, td.detailField2, td.detailField3 FROM Detail td WHERE " +
                    " td.master.id = t.id)) FROM Master t WHERE t.id = ?1")MasterHelper and DetailHelper have only the fields i want to query, getters and setters, and a constructor matching the SELECT NEW.. in @NamedQuery :
    public class MasterHelper implements java.io.Serializable {
        private String field1;
        private String field2;
        private String field3;
        private <DetailHelper> detailList;
        //Constructor matching SELECT NEW
        public MasterHelper(String field1, String field2, String Field3, List detailList) {
           this.field1 = field1;
            this.field2 = field2;
            this.field3 = field3;
            this.detailList = detailList;
         //getters and setters
    public class DetailHelper implements java.io.Serializable {
        private String field1;
        private String field2;
        private String field3;
        //Constructor matching SELECT NEW
        public DetailHelper(String field1, String field2, String Field3) {
           this.field1 = field1;
            this.field2 = field2;
            this.field3 = field3;
         //getters and setters
    }So, basically when i query for a particular Master entity, what i want in return is a List of MasterHelper objects with just the fields i want; each MasterHelper object must include a list of MasterDetail objects, again with just the fields i want.
    When the above named query is executed by Toplink Essentials against an Oracle database, i get the following exception regarding the "second" SELECT NEW:
    EJBQLException
    Exception Description: Syntax error parsing the query [SELECT NEW
    ...unexpected token [SELECT]
    ...How can i achieve what i want? Doesn't JPA allows SELECT NEW inside SELECT NEW in named queries?
    Thanks in advance for any help.
    Edited by: savas_karabuz on May 16, 2008 3:59 AM
    Edited by: savas_karabuz on May 16, 2008 4:02 AM

    Hello,
    The build you are using is an older one, and there have been a few enhancements done for constructor expressions support (for instance
    https://glassfish.dev.java.net/issues/show_bug.cgi?id=1421)
    but an enhancement to allow constant values is still open: https://glassfish.dev.java.net/issues/show_bug.cgi?id=2452
    Best Regards,
    Chris

  • Duplicate annotation - named query

    Hi,
    Jdeveloper Studio Edition Version 11.1.2.3.0.
    I added a named query to EJB bean, but I receive the following message:
    Error(13,1): duplicate annotation
    @NamedQueries( { @NamedQuery(name = "MyEntity.test", query = "SELECT /*+ FIRST_ROWS */ DISTINCT     f1.cid AS CONID\n" + JPQL Syntax error. What could be the problem?
    Thanks!

    Can you paste the complete NamedQueries annotation bit please ?

Maybe you are looking for

  • Can't boot installation cd on my Macbook pro 8.1

    Hi everybody, I am trying to install archlinux for dualboot with os x. The problem is that no matter what I do I just can't boot the installation CD. First I come to the normal screen where I can choose to boot archlinux, boot existing os, do memtest

  • Microsoft Access 2010 Creating a Form from Multiple Tables

    Hi. I am brand new to Microsoft Access and have had some exciting success making forms from single tables. This has made my data entry life much easier. However, I am continually stumped on one form I want to make. I would like to make a form that wi

  • Read image from scanner

    i want to interact with hardware(scanner) in java i want to read image and store in database for this 1.) i want to read image from scanner 2.) how do i start scanner process from where i gonna start plz help me to interact with hardware

  • Batch-removing keywords

    For some reason, a bunch of photos in my iPhoto library (v '09) have ended up with a wrong keyword - probably about 200 photos or so. The keyword in question (the name of a lens) is used (correctly) for lots of photos in the library, but I need to re

  • Older MacBook Pro connecting to iPhone 5.

    I am trying to connect an iPhone 5 to an older MacBook Pro. It is too old to update to Mountain Lion but needs an update for a newer iTunes. What is the latest I can run on? It's currently on OS X 10.4.11.