Toplink named query returns maximum 1413 results

Hi all.
As the heading states, I have a Toplink named query that returns 1413 results when it should return 3030. Is this configured somewhere? thanks in advance.

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

Similar Messages

  • TopLink named query issue

    We are using Jdeveloper 10.1.3.3, TopLink, ADF JSF Faces. I have an issue with TopLink named query. I am passing a value to parameter defined in the TopLink named query. The problem is that the parameter value is not being set when JSP page is loading for the first time and TopLink named query is not returning any results. When I click a button or refresh the page or some user action, then only the parameter value is set in the TopLink named query and returning the query results.Is this TopLink issue or is there any way to invoke action to fire the TopLink named query with the parameter value being passed at the time of loading JSP page ?
    Our project is held up due to this issue and I will highly appreciate if someone can help on this?
    Thanks in Advance.

    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

  • Adding "order by" functionality to the expression of a toplink named query

    hello,
    using JDev 10.1.3, I have made a Toplink named query findCustomersByCompany with a parameter company (String) to pass the name of the company of interest. I used the expression option from the format tab with"1.companyId LIKE IGNORE CASE company".
    The selection works fine but now I want the results to be ordered by customer name, the native order in the database is based on creation date.
    How can I add the order by clause to my named query using the expression format?
    kind regards,
    Nemata

    Look at http://www.thespot4oracle.com/SQL/re-6593_Adding-an-ordering-clause-using-a-TopLink-amendment-method.aspx
    Hope this helps.

  • 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

  • Toplink named query and firstrow

    In one of our projects we have a need to chunk records returned by a Toplink query.
    For example if a query retrieves 1000 rows we need to chunk records in batches of a variable number.
    Lets assume for this one request we need to chunk these 1000 rows in batches of 50 records. Is there a way to do this with Toplink?
    I tried to create a named query and then am setting the first row to 0 and max rows to 20
    And in a loop I am adding 20 to the value of the first row.
    This does not work. The first time the query runs the first row = 0 and the max rows = 20 and I get 20 records back as I expected, but the next time the query runs after I change the value of firstrows to 21 and I do not get any records back even though the DB has a 1000 records.
    Is it possible to do this sort of batching of the result set? I appreciate any pointers on how to solve this
    Thanks a lot for the help

    Hello,
    MaxRows is independent of firstResult in TopLink; unless using a database that supports pagination, MaxRows is applied to the statement, and then firstresults used on the returned resultset to skip to the desired first row. So, the driver would return 20 rows, and then firstResult skips to row 20 - so nothing gets returned.
    MaxRows and FirstResult are used in TopLink as the range you want to be returned. So both need to be incremented so that the difference between them is the max number of rows you want returned - MaxRows could be better described as a LastResult instead.
    Best Regards,
    Chris

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

  • Can a named query return a Vector of ReportQueryResult objects?

    TopLink experts,
    I would like to know if I can use the method executeQuery() defined in the Session interface to call a predefined named query, which returns a Vector ReportQueryResult objects rather than a Vector of a given domain class objects. If the answer is yes, then how?
    Many thanks for the help!

    I checked the available types of named queries from TopLink 9.0.4.5 Workbench and the ReportQuery type is not on the list. Only ReadObjectQuery and ReadAllQuery are available in its type dropdown list and both of these types would return an object of the descriptor (or say the domain class) where the named query is defined.
    How can I add a ReportQuery type named query to a descriptor in the Workbench? Please help!

  • 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

  • "where contains" in Toplink named query

    I´m using Toplink named queries to find documents in database. How can i use a parameter "keyword" inside an sql-statement? The statement looks like:
    select score(1), ID_DOCUMENTS_INDICATED, nvl(NAME,'--'), CREATE_DATE, LAST_UPDATE, USER_ID from IFCOB_DOCUMENTS_INDICATED where contains(BLOB_CONTENT, #keyword , 1) > 0;
    "keyword" is a String from an users input. I´m using JDeveloper 10.1.3 so there isn´t any TextWizzard for my jspx-application. Any solutions?
    Thx, Don

    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

  • JDO: Query returns too many results.

    Hello,
    I want to get some DO-Entities from an empty table. When I execute the query I retrieve more than 2 000 000 000 results what is definitly too much for an empty table. The DO has an one-to-many relationship to another class and a many-to-one relationship to another one.
    The .map and .jdo files of the class and the classes in relation made accordng to the explanations in the Development Manual chapter "Mapping Persistent Classes to Database Tables" (so including DFG- and embedded- attributes). Enhancing is successfull and the work with the classes that doesn't have relationships also.
    The query looks like this:
                   manager = getPersistenceFactory().getPersistenceManager();
                   String filter = "version == \"" + version + "\" && postingLevel == \"" + postingLevel +
                                       "\" && closingPeriod == " + closingPeriod + " && bunit== \"" + bunit + "\"";
                   Query query = manager.newQuery(AD_DO_Protocol.class, filter);
                   Collection col = (Collection) query.execute();
    I also tried to use the extent with the same result.
    Any ideas?
    Regards,
    Jan

    Hi Guru,
    first of all in that certain method of the DAO I'm not able to use the primary key because I implement a check if an entity with the given attributes allready exists.
    Second I don't want (and as I think don't have) to write the mentioned java function for the following reason: There must be max one result for the given query. Thats a constraint implied by our business logic.
    In fact at the given moment there must not be a single result because the table IS EMPTY!!!
    Any other ideas?
    Thx and regards,
    Jan

  • Query returns too many results

    I have this query that returns 118,900 records when I try to
    add
    or oth_tchname_ssn like '%123456789%'
    at the end of the query.
    When I remove the or oth_tchname_ssn like '%123456789%' it
    returns 32 records which seems about right.
    Any ideas as to where my cfquery statement is wrong?
    Thanks
    Emmanuel

    This was solved by adding parent tags.

  • Entity-Named Query Caching - Need live results from DB not Cached

    I've developed an application EJB3 web application which uses Entity Beans and NamedQueries to retrieve my results.
    Aswell as my main EJB3 web application I also have an external interface (Oracle Stored Procedure) which is updating data in my database tables. The problem is that the when the NamedQueries are called they only bring back "Cached" resultsets and not the live results that exists in the database at that time. If my Stored Procedure updates a value (or if I update a value via Toad for testing) the NamedQuery does not bring back these changes. From what I have read about NamedQueries it seems that they do actually query the live db but send back the cached values for performance reasons.
    Is there a way to turn off caching of Query results?
    If not is there another way to deal with this issue?
    ps. I'm using Jdev 10.1.3.4 and appserver 10.1.3.1

    Anyone?

  • TopLink doesn't sort data received using Named query

    Hello!
    I'm trying to build a Tree table using a TopLink Named query in my application.
    There are Id, Parent|_Id, Code and Name columns in the corresponding database table, where Id and Parent|_Id are linked together by Foreign key (typical tree). I used TopLink to describe this table in the Model part of my application. There I wrote a Named query, without using a query constructor (not Expression radio button, but SQL radio button). Here the text of query:
    select * from regions a connect by prior a.Id = a.Parent_Id start
    with a.Id is null order by a.Code
    Then I created a Data control and tried to build a JSF page with data based on this query, as tree-table.
    But I discovered the fact, that data under the same node on the same leaf level of the Tree are not sorted by code on the JSF page. For example, data may be situated as follows (Code - Name):
    2. wwwwwwwwwwww
    2.3.kkkkkkkkkkkk
    2.1.fffffffffffffffffffff
    2.2.oooooooooo
    1. qqqqqqqqqqqqqqqq
    1. 2. lllllllllllllllllllllllllllll
    1. 1. hhhhhhhhhhhhhh
    etc.
    I verified this query on other environment (PL/SQL Developer, SQL+), but didn't found such unsorted results anywhere.
    Please, give me an advice to avoid this problem.
    Thanks.

    Hi
    Something to do with TreeMap(TreeSet). I tried with TreeSet but it didn't work. Here is the code :
    In servlet :
    Connection lConnection = getConnection(pRequest);
    String lSQL = "";
    Statement lStatement;
    ResultSet lResultSet;
    Hashtable lLtypeHashtable = new Hashtable();
    lStatement = lConnection.createStatement();
    lSQL = "SELECT RCID,RCMEANING FROM REFERENCECODES WHERE RCDOMAIN = 'LOCATIONTYPE' AND RCROWSTATE > 0 order by RCMEANING";
    lResultSet = lStatement.executeQuery(lSQL);
    while(lResultSet.next())
    String lRcid = lResultSet.getString(1);
    String lRcmeaning = lResultSet.getString(2);
    lLtypeHashtable.put(lRcid.trim(),lRcmeaning.trim());
    if(lResultSet != null) lResultSet.close();
    if(lStatement != null) lStatement.close();
    pRequest.setAttribute("LtypeHashtable",lLtypeHashtable);
    //Below Query is executed when one data from select element is selected
    String lLType = DisplayUtilities.getString(pRequest.getParameter("LType"),true);
    //LType is name of select element in JSP.
    if (lLType != null)
    lSQL = lSQL + " AND " + lUpperCaseFunction + "(LOCATIONTYPE)" +
    " = " + DBUtilities.formatString(lLType.toUpperCase());
    pRequest.setAttribute("rLType",lLType+"");
    In JSp :
    <%
    Hashtable lLtypeHashtable = (Hashtable)request.getAttribute("LtypeHashtable");
    %>
    <TR>
    <TD width="15%"> <div align="left">
    <select name="LType" size="1" >
    <option Value="">< Select ></option>
    <%
    if(lLtypeHashtable != null)
    Enumeration enum = lLtypeHashtable.keys();
    while(enum.hasMoreElements())
    String key = (String)enum.nextElement();
    String value = (String)lLtypeHashtable.get(key);
    String flagBack = "";
    if(key.equals((String)request.getAttribute("rLType")))
    flagBack = "selected";
    %>
    <option Value="<%=key%>" <%=flagBack%>><%=value%></option>
    <%
    %>
    </select></div>
    </TD>
    </TR>
    How should I implement TreeSet?
    Looking forward for an early reply.
    Thanks.

  • 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);

  • 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

Maybe you are looking for