Questions on Named Query

We have a few questions about named query.
According to the Toplink documentation, we can register the named query in 2 places.
1. Register the name query in the “query manager” in a Session level - The documentation said that these are for “GLOBAL” queries.
2. Register the name query in the “query manager” in a Descriptor level. These “Descriptor level” query can be defined via the Toplink workbench or defind via Java code and load in the Descriptor via a post-project load amendment method. The documentation also mentioned that once the project is login, we cannot add named query to the descriptor.
We have a few questions.
All querys are related to a class, so what do we mean by “GLOBAL” queries ? What is this “GLOBAL” means.
Is there any restriction in adding query to a session. Can we add query to a session after the session is login ?
What we like to achieve is something like this.
Ask the session for a query “findElectionByEmployee”, if nothing returns, construct the query, add this named query to the session.
Can we ask a clientSession for a query using getQuery(string)?
Or we can only ask a serverSession for a query ?
How about adding query to a session, can a clientSession add a query back to the parent ServerSession, or we need to add the query directly to a serverSession ?
We have hundreds of queries, not all of them used all the time, so adding the query to the session “on demand, or Just in Time addition”, will be most memory saving rather than starting the system with hundreds of query.
Another issue we have about using descriptor based query, specially those that is define via the toplink workbench, is that it create sort of an administrative single point of entry. For a system that have a lot of query, to single file the creation of the query to a single person, or a few people, can be administratively difficult, even though we appreciate the “central and single point of control aspect of it.
So what is your observation in the use of named queries with your other clients ?
Is that a popular feature that your customer use ? Do they like to define the query in Workbench, can this solution “administratively scale” ?
Do you see “just in time” add of query to a session, if that is all possible.
Currently we have a simple query mechanism, each DAO method eg findElectionByEmployee, will contruct the query, with the expression builder, expressions etc and after one execution, throw that away and redo the same thing again in the next method invocation.
We want to avoid that but we do not want to centralized the definition to a central “Toplink Mapping” person. For a fairlt big system like ours, that have 20-30 DAO with hundreds of “finder” methods, it is too difficult to centralized.
What is your thoughts on this and if there is any white paper of best practice that you can point us to, we be most appreciated.

In answer to your technical questions, the only difference between descriptor level named queries and session level named queries is where the query is stored. Queries stored at the session level must have unique signatures, queries stored in the descriptor require unique signatures from other queries on the same descriptor but not queries on other descriptors or sessions.
Queries at the session level can be on any class, queries at the descriptor level must on that descriptor's class.
A ServerSession's query can be found from a ClientSession but queries added to a ClientSession will only be available to that ClientSession and will dispose when the ClientSession is released.
As to the questions about manageability it really is up to you to evaluate. If it is important to your organization that queries are moderated centrally then controlling them at the project level would provide for that. If that is not an important requirement then moving to a dynamic model would be less overhead, and headaches of having numerous people working on the source to and redeploying the same application repeatedly. But in general a combination of the two approaches, based on how often a particular query is used, would probably be best.
--Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Question on named query

    Is it posssible to define one named query to handle the following three kinds of queries?
    select * from vista_order where brand = #brand and factory_order_no between #fromValue and #toValue order by #sortType
    select * from vista_order where brand = #brand and order_no between #fromValue and #toValue order by #sortType
    select * from vista_order where brand = #brand and nsc_order_no between #fromValue and #toValue order by #sortType
    We'd like to supply the column names (i.e. factory_order_no, order_no, or nsc_order_no) at runtime, in addition to the arguments. Does TopLink support that?
    Thanks.
    Haiwei

    Haiwei,
    No, TopLink's named queries only support argument substitution and not field/column. You could use a named re-direct query to dynamically create these queries but still have the simple API for query execution.
    Cheers,
    Doug

  • 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

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

  • Snowflake dimension: named query vs. database view

    A test question features a Product table with a Product Size code; Product Size description is taken from ProductSize table. As far as I can tell, the question asks me to choose between (a) setting up a database view joining Product and ProductSize, and
    (b) doing the join in a data-source-view named query. I don't see a clear winner. (My thinking is as follows.  Yes, he view would speed up the processing, even if not materialized. On the other hand, with a small dataset, the performance gain would be
    minor in absolute terms. Do I want to have an extra database object in the picture?) Yet the question's author does. Can anyone advise please?  

    Hi Demyan,
    According to your description, you want to know which is better, using named query in datasource view or using database view, right?
    Based on my research, there is no performance differences between using named query in datasource view and using database view because they both result in SQL query being sent to the source system. Here is a blog which discuss this issue.
    Consistency: If you already have logic in database views, I would continue to use them. As long as you know that you go to one spot to view/change the logic. Putting the logic in 2 different spots could lead to confusion.
    Security Permissions: often you may not have permission to alter the source databases, in this case you have no choice but to setup named queries in the dsv.
    Reference
    http://geekswithblogs.net/darrengosbell/archive/2006/09/05/90278.aspx
    http://bennyaustin.wordpress.com/2013/07/16/dbview/
    Regards,
    Charlie Liao
    TechNet Community Support

  • Named query, primary keys must not contain null

    We have an question on the named query. Here is the scenario:
    Class JoinClassC (id, name, desc, comment) is mapped to two tables Join_Table_A (id, name, description) and Join_Table_B (id, name, comments); Join_Table_A is the primary table; two tables are associated via primary key.
    Defined a named query (findByName, ReadAllQuery/SQL) for JoinClassC descriptor. The sql is:
    SELECT a.ID,a.NAME,a.DESCRIPTION,b.COMMENTS FROM JOIN_TABLE_A a, JOIN_TABLE_B b WHERE a.NAME=#name AND a.ID=b.ID AND a.NAME=b.NAME
    Getting QueryException while executing the query. Here is the trace:
    [3/2/05 13:50:24:795 EST] f8b62aa SystemOut O 2005.03.02 01:50:24.795--ServerSession(738697921)--Thread[Servlet.Engine.Transports : 4,5,main]--Connection(1095574161)--SELECT a.ID,a.NAME,a.DESCRIPTION,b.COMMENTS FROM JOIN_TABLE_A a, JOIN_TABLE_B b WHERE a.NAME='persistence' AND a.ID=b.ID AND a.NAME=b.NAME
    2005.03.02 01:50:24.835--ClientSession(1127670417)--Thread[Servlet.Engine.Transports : 4,5,main]--Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4.4) (Build 040627)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRow(
         USER04.JOIN_TABLE_B.ID =&gt; 2
         USER04.JOIN_TABLE_A.NAME =&gt; persistence
         USER04.JOIN_TABLE_A.DESCRIPTION =&gt; FJF Persistence Fram
         USER04.JOIN_TABLE_B.COMMENTS =&gt; The Persistence Fram)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadAllQuery(com.ford.it.persistence.unittest.dom.JoinClassC)Local Exception Stack:
    Exception [TOPLINK-6044] (OracleAS TopLink - 10g (9.0.4.4) (Build 040627)): oracle.toplink.exceptions.QueryException
    Exception Description: The primary key read from the row [DatabaseRow(
         USER04.JOIN_TABLE_B.ID =&gt; 2
         USER04.JOIN_TABLE_A.NAME =&gt; persistence
         USER04.JOIN_TABLE_A.DESCRIPTION =&gt; FJF Persistence Fram
         USER04.JOIN_TABLE_B.COMMENTS =&gt; The Persistence Fram)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Query: ReadAllQuery(com.ford.it.persistence.unittest.dom.JoinClassC)
         at oracle.toplink.exceptions.QueryException.nullPrimaryKeyInBuildingObject(QueryException.java:542)
    Adding b.ID to the sql select will solve the problem.
    Question: does the primary key must be present in the sql select to run this kind of query? Any way to work around the restriction?
    Your help would be greatly appreciated.
    Haiwei

    The problem is that you need to select both primary keys for the multiple table descriptor.
    i.e.
    SELECT a.ID,a.NAME,a.DESCRIPTION,b.ID, b.COMMENTS FROM JOIN_TABLE_A a, JOIN_TABLE_B b WHERE a.NAME=#name AND a.ID=b.ID AND a.NAME=b.NAME
    Your SQL needs to return the same data that TopLink would have selected, which includes the primary key for both tables. TopLink expects both a.ID and b.ID fields in the select, because your only select one and the field names are the same TopLink thought the ID field was for b.ID not a.ID, if you select both it will be ok.

  • Named query in Entity Bean - Problem with embedded class

    Hello Forum,
    I'm trying to set up a named query in my Entity Bean and I'm unable to get
    it up and running for an embedded class object.
    The class hierarchy is as follows:
             @MappedSuperclass
             AbstractSapResultData (contains dayOfAggregation field)
                     ^
                     |
            @MappedSuperclass
            AbstractSapUserData (contains the timeSlice field)
                     ^
                     |
              @Entity
              SapUserDataThe named query is as follows:
    @NamedQuery(name = SapUserDataContext.NAMED_QUERY_NAME_COUNT_QUERY,
                                query = "SELECT COUNT(obj) FROM SapUserData AS obj WHERE "
                                         + "obj.sapCustomerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_CUSTOMER_ID
                                         + " AND "
                                         + "obj.sapSystemId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SYSTEM_ID
                                         + " AND "
                                         + "obj.sapServerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SERVER_ID
                                         + " AND "
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATION
                                         + " AND "
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime")The query deploys and runs except that part:
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONI don't see any difference to the part of the query accessing the timeSlice
    field which is also an embedded class object - I access it in exactly the same way:
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime"The problem is that the complete query runs on JBoss application server
    but on the SAP NetWeaver application server it only rund without the
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONpart - If I enable that part on SAP NetWeaver the server complains:
    [EXCEPTION]
    {0}#1#java.lang.IllegalArgumentException: line 1: Comparison '=' not defined for dependent objects
    SELECT COUNT(obj) FROM SapUserData AS obj WHERE obj.sapCustomerId= :sap_customer_id AND obj.sapSystemId= :sap_system_id AND obj.sapServerId= :sap_server_id AND obj.dayOfAggregation.calendar= :day_of_aggregation AND obj.timeSlice.startTime= :timeSliceStartTime AND obj.timeSlice.endTime= :timeSliceEndTime
                                                                                                                                                                                                 ^I know that this isn't an application server specific forum but the SAP NetWeaver server is the most strict EJB 3.0 and JPA 1.0 implementation I've seen so far so I think I'm doing something wrong there.
    Someone in the SAp forum mentioned:
    The problem here is that you compare an input-parameter with an embeddable field of your entity.
    Regarding to the JPQL-grammer (spec 4.14) you are not allowed to compare
    with the non-terminal embeddable field but with the terminal fields of your
    embeddable. Stating that your embedded class might have the fields
    startTime and endTime your JPQL query might look like this:
    Query q = em.createQuery("SELECT count(obj.databaseId) FROM SapUserData obj WHERE obj.timeSlice.startTime = :startTime AND obj.timeSlice.endTime = :endTime");
    q.setParameter("startTime", foo.getStartTime());
    q.setParameter("endTime", foo.getEndTime());
    q.getResultList();
    This limitation in the JPQL grammar is rather uncomfortable.
    An automatic mapping of the parameter's fields to the terminal fields of your
    embedded field would be more convenient. The same can be said for lists
    as parameter-values which is possible in HQL, too. I think we have to wait
    patiently for JPA 2.0 and hope for improvements there. :-)
    With that help I was able to get it up and running for the timeSlice field but
    I don't see the difference to the dayOfAggregation field which is also just
    another embedded class using an object of a class annotated with
    @Embeddable.
    The get method of the dayOfAggregation field is as follows:
         * Get method for the member "<code>dayOfAggregation</code>".
         * @return Returns the dayOfAggregation.
        @Embedded
        @AttributeOverrides({@AttributeOverride(name = "calendar", /* Not possible to use interface constant here - field name must be used for reference */
                                                column = @Column(name = DayContext.COLUMN_NAME_DAY_OF_AGGREGATION,
                                                                 nullable = false)),
                             @AttributeOverride(name = "weekday",
                                                column = @Column(name = DayContext.COLUMN_NAME_WEEKDAY,
                                                                 nullable = false)),
        public Day getDayOfAggregation() {
            return this.dayOfAggregation;
        }The link to my question in the SAP forum for reference:
    https://www.sdn.sap.com/irj/sdn/thread?messageID=3651350
    Any help or ideas would be greatly appreciated.
    Thanks in advance.
    Henning Malzahn

    Hello Forum,
    got a response in the SAP forum - Issue is a bug in the SAP NetWeaver
    app. server.
    Henning Malzahn

  • Which one should we go for Named Query or Redirect Query???

    Hi all,
    We are in the process of implementing top-links in our project so we are working with different queries of top-links. We have made most of them many of the queries are clear in their concept and implementation. It was a very nice experience working for now. but i have some un-answered questions like
    ---- what is the difference between Redirect query and Named query (Both seems to be the same... to me). we got output using Redirect query but i am totally confused because in documentation it gave that redirect query is used in situation where query is complex and named query cannot be used for it.But i personally feel some things about redirect query .....
    -- Query implementation is itself complex and confusing .
    -- What operations can we do in the static method where we are redirecting the query.
    -- Almost of all the methods in the 'ClassDescriptor ' are deprecated...
    -- Not Much Implementation code is available in Top-link docs nor On-line.
    That's why i am not able to decide which query i must use for a complex query i would prefer named query from myself because of its simplicity and straight forwardness.
    Can any one clear my questions.....
    Many questions in days to come........
    Thanks in Advance
    Adil

    no reply ..... :-)

  • Native TopLink named query with named parameters

    Hello,
    Defining my metadata in native TopLink xml and using the native TopLink's Session interface I can access and successfully execute a named query using positional parameters (parameters passed to match the ?1 ?2 etc). I used for this the Session.executeQuery(String, Class, List) method e.g.
    select p from Person p where p.name = ?1
    Now, how can I get the same Session to execute named queries using named parameters? None of the Session.executeQuery methods seem suitable ... Am I missing anything here? e.g.
    select p from Person p where p.age = :age
    I can't find in Session http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/b13698/oracle/toplink/sessions/Session.html a good match for this use-case. I would expect something like:
    Session.executeQuery(String queryName, Class target, List argNames, List argValues)
    or
    Session.executeQuery(String queryName, Class target, Map argsKeyedByName)
    but can't find any good match, can anyone please enlighten me?
    Thanks in advance,
    Best regards,
    Giovanni

    Hello Chris,
    Many thanks for your response. I am sorry if I did not explain my problem properly.
    Suppose I already defined a named query in the metadata XXXProject.xml using the <opm:querying ... this JPQL named query "customFinder" already exists and would look something like:
    select p from Person p where p.firstname=:firstname and p.lastname=:lastname and p.birthdate=:birthdate
    now say you want to execute this query from the Session:
    Vector args = new Vector();
    // how do you know the order? you shouldn't know the order!
    // you know only the parameter names and that's what I mean
    // about named parameters
    // This args setup is wrong ... I need a way to specify to which
    // parameter name each argument corresponds to. In other words
    // if the named query where criteria order of parameters is modified
    // perhaps because of pruning composite keys etc you won't break the
    // existing code ...
    args.add(new Date());
    args.add("Azua");
    args.add("Giovanni");
    Session session = ...
    session.executeQuery("customFinder", Person.class, args);
    JPA supports both type of queries positional parameters and named parameters. Your explanation above is only for the first, my question refers to the later.
    I have not yet found the api for this ... though I am investigating along the lines of:
    Query query = session.getQuery("customFinder");
    and then try to assign the arguments in the same order that the parameters are defined in query or?
    Thanks in advance,
    Best regards,
    Giovanni
    Edited by: bravegag on 29.05.2009 08:06

  • 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

  • Clone of TopLink named query

    One of our projects here has a requirement where they'd like to modify, at runtime, the named query defined in the Mapping Workbench.
    One example is to set the refresh depth level (cascadePrivateParts, cascadeAll, for example) for the named query so that the defined query could be used in different scenarios with slightly different query options to get different query results.
    To support this, we will need to clone the query. See the sample code below:
    ObjectLevelReadQuery toplinkQuery = null;
    ObjectLevelReadQuery queryClone = null;
    Descriptor descriptor = session.getDescriptor(targetClass);
    DescriptorQueryManager queryManager = descriptor.getQueryManager();
    toplinkQuery = (ObjectLevelReadQuery)queryManager.getQuery(queryName);
    queryClone = (ObjectLevelReadQuery)toplinkQuery.clone();
    We try to use the clone method in DatabaseQuery. It seems to be working fine from the unit testing.
    Could someone provide me some information regarding the overhead (performance penalty) the clone method introduces?
    Thanks.
    Haiwei

    James,
    Thanks very much for your quick response.
    "The difference between using the clone vs not using the clone, is that clone (and changing the query) will trigger the query to no longer be prepared. This means that the query will need to re-generate the SQL for every execution."
    Is this always true or it depends on what query options got changed?
    I tried the cloneQuery with cloneQuery.cascadePrivateParts(). It seems that (from the trace) it still uses the prepared SQL. Here is the trace:
    in testQuery .....
    [3/8/05 15:27:47:027 EST] d510d51 SystemOut O 2005.03.08 03:27:47.027--ServerSession(1090797828)--Thread[Servlet.Engine.Transports : 1,5,main]--Connection(290525521)--SELECT * FROM QUOTE WHERE ID IN (?,?)
         bind =&gt; [1, 2]
    [3/8/05 15:27:47:037 EST] d510d51 SystemOut O 2005.03.08 03:27:47.037--ServerSession(1090797828)--Thread[Servlet.Engine.Transports : 1,5,main]--Connection(759639367)--SELECT NAME, ID, VERSION FROM USER04.SUBQUOTE WHERE (QUOTE_ID = ?)
         bind =&gt; [1]
    [3/8/05 15:27:47:037 EST] d510d51 SystemOut O 2005.03.08 03:27:47.037--ClientSession(219090191)--Thread[Servlet.Engine.Transports : 1,5,main]--client released
    A separate question, the cascade option is not configurable in the Mapping Workbench, is this something that TopLink deliberately does not provide?
    Thanks again for your assistance.

  • 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

  • A few Questions on ABAP Query

    Hi Guru's
    I would like to ask some questions on ABAP query.
    1. Can you transport abab queries? Should it only be Global or you can also transport Standard Areas?
    2. Once transported, am i able to change query?
    Thanks,
    Jograd

    hi....
    you can transport a quary but for that the quary should be an object itself or attached to some object
    and
    if once transported to production....you cannot change it there and for changing you have to get it in developement sysytem and then make any change.
    regards

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

  • Order by clause with Named Query

    hi
    i have to give order by clause in Named Query
    how we have to specify is can any body help
    thanks
    Harish

    Assuming an Entity called Handset:
    select h from Handset h order by h.description

Maybe you are looking for

  • Sd tender Process(SAP R/3)

    Hi sd gurus, Here we r implementing R/3- ECC 6 Client name is ABC Here client floats tender  to parties regarding rate & quantity, Then ABC company recievs from Tender on quantity & rate from various parties. Then ABC management does negotiation with

  • Works locally, but error when put online

    hi, I compiled the stratus sample and put it on my own server. I can connect to the stratus.adobe.com for both local de-bug and visiting by browser on the server. But I failed to have key exchange for the deployed one, while it works successfully for

  • Help with the insert table/form tool in BIP 10.1.3.2.1

    Hi, I'm trying to use the insert table/form tool in BIP, and running into some issues that I don't understand. First off, my data coming in looks like this (left column of tool): Rowset --- Row ------ Customer ID ------ Customer Name ------ Customer

  • IOS 4 caused my iPhone 3GS to die :p

    Hi guys, Just got my replacement 3GS through the post yesterday, was away today so only just managed to get it updated to 4. It got just over half way on the iPhone progress bar and its not progressing any further. Any help? Its going back to the sho

  • H264 colours (colors)  UGLY! What can I do?

    I compressed our movie trailer to H264 using compressor (2.3) for web delivery. If I watch it in Quicktime (7.1.6) or Safari (2.0.4) then the colours are washed out, pale, unsaturated and it looks overexposed - basically rather ugly. If I watch it in