Named query creates wrong cast: CAST (? AS VARCHAR(32672))

Hello!
I'am working with Toplink on DB2 - which works great, so far - but now I face the following problem:
A named query produces the following sql-code:
... WHERE (SAMPLEFIELDNAME = CAST (? AS VARCHAR(32672) ))
The problem ist the cast: the data-base-fieldtype is a VARCHAR(255) so get an SQL-Exception. I can't change the database-schema, because this is legacy-stuff. I tried a lot (columnDefinition and length in @Column-annotation seem to be ignored at all) - but nothing worked.
Thank you!
Siegfried

Hi,
The DB2 Platform hard coded the casting of Strings to VARCHAR(32672) in the oracle.toplink.platform.database.DB2Platform class' writeParameterMarker method. So if the type is set to a String class on the argument, it will always be cast to VARCHAR(32672). You will need to override the writeParameterMarker method on a custom platform (extending DB2Platform) in such a way that if a string is given, VARCHAR(255) is used instead. That is, assuming all your strings are of size 255.
Best Regards,
Chris

Similar Messages

  • Toplink Named Query - Creating the Expression

    In JDeveloper, I have this scenario.
    I’ve created a:
    Name.java – private String name;
    Managed Bean – Name - id, Class - paperless.Name, Scope - session
    Toplink Named Query --> findUserProfile
    Type --> ReadObjectQuery
    In the format tab, I’m using “Expression” and it is “1. pp_Username EQUAL “#{id.name}”
    I’m trying to do a query on pp_Username where pp_Username equals the login name that I have stored in the session (id.name). I can only assume that I have my express written incorrectly. When I run it, I just get nothing. Any ideas?

    Go to your toplink map in the application navigator, select the descriptor in the structure pane and then click on the "Queries" tab in the editor pane. You should be able to configure your named query there.
    Hope this helps.
    Anuj

  • 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.

  • Creating Named Query: from OracleCallableStatement

    We have a great many PL/SQL Procs in an existing legacy system that return PL/SQL Boolean, that we wish to call from toplink.
    Ideally we would like to create Toplink Nameded queries that wrap the SQL call statements.
    Does anyone know if its possible to convert a call like the following into a Toplink named query?
    String domain = "COST CENTRE";
    String value = "OP";
    OracleCallableStatement xcall = (OracleCallableStatement) con.prepareCall(
    "BEGIN ? := SYS.SQLJUTL.bool2int(is_valid_value(?, ?)); END;");
    xcall.registerOutParameter( 1, OracleTypes.INTEGER);
    xcall.setString(2,domain);
    xcall.setString(3,value);
    xcall.execute();
    System.out.println ("Status = " + xcall.getInt(1));
    FUNCTION is_valid_value(
    p_rv_domain IN CG_REF_CODES.RV_DOMAIN%TYPE,
    p_rv_low_value IN CG_REF_CODES.RV_LOW_VALUE%TYPE
    RETURN BOOLEAN
    IS
    Many thanks,
    Lee.

    You can define Stored Procedure calls in TopLink through the StoredProcedureCall class. StoredProcedureCall allows you to define output parameters to access return values.
    Example:
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("is_valid_value");
    call.addNamedArgumentValue("DOMAIN", domain);
    call.addNamedArgumentValue("VALUE", value);
    call.addNamedOutputArgument("RESULT", "RESULT", Integer.class);
    List results = session.executeSelectingCall(call);
    boolean value = ((Integer) ((Map) results.get(0)).get("RESULT")).intValue() == 0;
    However what you seem to be accessing is a stored function, not a procedure. To access a stored function from TopLink you must use an SQLCall and select the return value through the DUAL table.
    Example:
    SQLCall call = new SQLCall("Select SYS.SQLJUTL.bool2int(is_valid_value(" + domain + ", " + value + ")) from dual");
    List results = session.executeSelectingCall(call);

  • 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,

  • Creating a Java named query?

    Hi,
    From the application developers manual; is it implied that named queries can be created using the Oracle Toplink API in Java; i.e out of the workbench but I have not been able to find any references to this elsewhere. Does anyone have any information on this? i.e creating the named query in Java code and then adding it to the project deployment.
    In addition, is it possible to have it such that if a named query expects 4 arguments; the Java code is written to check if there are any null values passed in, and if the values are null those columns wlil be removed from the query.

    There are really two types of queries that apply.
    Named queries being those queries defined in Java code at application start up that take a fixed number and types of parameters. These queries are typically added using descriptor after-load methods. In the MW you select the static after-load method where you wish to define your queries. As of TopLink 9.0.4 it is possible to define your named queries with arguments directly in the MW without an after-load method.
    Redirect queries are queries where TopLink invokes your method at runtime to execute the query. This approach allows for your code to selectively build the where clause based upon the arguments passed in.
    Some links into the docs that may be of interest:
    after-load: http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10316/dscriptr.htm#1014978
    Using named queries: http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10313/queries.htm#1146839
    Redirect queries: http://download-west.oracle.com/docs/cd/B10464_01/web.904/b10313/queries.htm#1141580
    Doug

  • Create Named Query with no descriptor?

    I have a very simple query(see below). I'd like to use it as a named query instead of recreating it everytime. I wonder if there is a way I can add it to somewhere without using a descriptor so that I can retrevie it from the session.
    Thanks,
    Wei
    ValueReadQuery query = new ValueReadQuery();
    query.setSQLString("SELECT SYSDATE FROM DUAL");
    Object obj = (Object) session.executeQuery(query);

    There is an "addQuery(DatabaseQuery q)" on the Session interface that should do the trick. So create your session, and then do:
    ValueReadQuery query = new ValueReadQuery();
    query.setSQLString("SELECT SYSDATE FROM DUAL");
    session.addQuery("getDate", query);
    Then later you should be able to:
    session.executeQuery("getDate");
    - Don

  • 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.

  • 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

  • FindByPrimaryKey named query

    When creating a named query 'findByPrimaryKey', the workbench says 'The query for this finder will be generated at runtime.'
    The object in question HAS a primary key set, but the sql generated from a findByPrimaryKey query doesn't contain a where clause, so it returns the first result:
    session.executeQuery("findByPrimaryKey", RequestDelivery.class, "41");
    generates the following sql:
    ServerSession(20012340)--Connection(31335791)--SELECT DELIVERY_ID, CONTACT_ADDRESS, FILM_DELIVERY, DELIVERY_DATETIME, CONTACT_METHOD, REFLOC_ID, REQ_ID FROM REQUEST_DELIVERY
    which is quite obviously wrong..
    Is there something I'm missing, or am I misusing the findByPrimaryKey query.. ?

    Hi,
    The findByPrimaryKey query is kind of meant as a reserved name for entity finders. This is why you are seeing the comment that it will be generated for you. When you don't use CMP then you can still use this name for a query, but you would have to define the query in code. I would recommend that you actually use a different name, though to prevent confusion.
    -Mike

  • Retrieving array of objects using Named Query

    Can i retrieve an array of objects using a Named Query? The execute query method of Session returns only an Object but not an array. Please let me know if there is any possibility.
    Thanks in advance,

    Hi,
    You define a named ReadAllQuery query object, and after query execution, you can cast the returned Object as Vector, and further convert it to an array.
    King

  • How to write named query if we want to use IN syntax in our sql statement?

    I cannot find a suitable category about named query, so please move to appropriate place if there is any.
    When we write named query, below statement is fine.
    Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field1 = :input1");             q2.setParameter("input1", "value1");
    Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
    Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");             q2.setParameter("input1", "3633, 3644");
    Can anyone suggest? Thanks.

    roamer wrote:
    Now, my question is, how can I write this type of query when we want to use the IN sql syntax? As below statement CANNOT return correct results. Even I tried to put a pair of single quote [ ':input2' ], it won't help also.
    Query q2 = em.createQuery("SELECT o FROM Table1 as o WHERE field2 IN (:input2)");
    q2.setParameter("input1", "3633, 3644");
    Can anyone suggest?The above is in your code right? Not in some configuration file?
    Then you do it the same way as with regular jdbc/sql.
    1. You start with a collection of values - call it collection A.
    1. Create a for loop that dynamically creates the string using 'bind' variables (whatever you want to call the 'colon' entity in the above).
    2. Call the createQuery method using the string that was created
    3. Create a second loop that iterates over A and populates with setParameter.
    Pseudo code
            Object[] A = ...
            String sql = "SELECT o FROM Table1 as o WHERE field2 IN (";
            for (int i=1; i <= A.length; i++)
                  if (i == 1)
                     sql += ":input" + i;
                 else
                     sql += ",:input" + i;
            sql += ")";
            Query q2 = em.createQuery(sql);
            for (int i=1; i <= A.length; i++
                  q2.setParameter("input" + i, A[i-1]);
                  }By the way there is a jdbc forum.

  • IN operator in Named Query

    hi all,
    is it possible to create a named query containing the IN clause if yes how to pass the parameters , i have smth like that:
    "select * from tblUsers where employee_number in #param"
    what should be the type of the parameter?

    You can create a named query using an IN parameter, but you should be careful in doing this as an IN collection is not a valid parameter in SQL. TopLink will handle translating the IN as long as you are using dynamic SQL, or disable the prepare on the query. You can use Vector as the parameter value.
    i.e.
    ReadAllQuery query = new ReadAllQuery(Employee.class);
    query.setSQLString("select * from tblUsers where employee_number in #param");
    // Or: query.setSelectionCriteria(query.getExpressionBuilder().get("number").in(query.getExpressionBuilder().getParameter("param")));
    query.setShouldPrepare(false);
    query.addArgument("param");
    Vector args = new Vector();
    Vector param = new Vector();
    param.add(new Integer(1));
    param.add(new Integer(2));
    param.add(new Integer(3));
    args.add(param);
    session.executeQuery(query, args);
    // Or: session.executeQuery("findAllWithNumbers", Employee.class, args);

  • 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

Maybe you are looking for