"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

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

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

  • 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

  • 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

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

  • 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

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

  • 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

  • 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, 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 Expression in Toplink workbench

    Hi! All,
    I have a problem which I am not sure how to solve and would appreciate any help on this.
    I have Tables
    Company, Employee, EmployeeTaxType , TaxTypeVal
    Each is mapped to a java class with the same name
    I would like to find all Employee Objects for a company where (taxTypeVal.year=2005 and taxType.quarter=2)
    I cant seem to be able to build a Named Query expression which would produce the same result.
    It always returns All employees who belong to a company and have liabilities in either year =2005 OR quarter=2
    The expression that I wrote was
    AND
    1.companyBO.companyID EQUAL COMPANY_ID
    2.AND
    2.1.employeeTaxTypeBOs.taxTypeValBOs.quarter EQUAL QUARTER
    2.2.employeeTaxTypeBOs.taxTypeValBOs.year EQUAL YEAR

    Please post the SQL that is generated from TopLink, and the xml where you define the NamedQuery. What version of the MappingWorkbench and TopLink runtime are you using?
    Deepak

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

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

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

  • Named query problem, [TOPLINK-6008] error

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

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

Maybe you are looking for

  • Camera Roll to iCloud. How does this work?

    I need help with my photos on camera roll. I need to delete them to have more space on my phone to take more. I want to be able to keep the pics in my camera roll though. I have iCloud and a bunch of space on there. How do I know for sure that the pi

  • Need step by step instructions to configure SOAP sender adapter.

    Hell Friends I am new to SOAP Adapter scenario and am looking for some instructions that will guide me thro' step by step instructions. The scenario is that I am getting data from outside world and want to use a SOAP adapter and send it to XI. From X

  • TXT in language other than English doesn't even reach the called party

    Hello, Upgd my iPhone 3G to OS3.0 and added "Hebrew" successfully. However, sending txt messages in Hebrew doesn't even reach the other party, only English does. Anyone having similar issues?

  • Renaming issue

    Usually I rename like this: YYYYMMDD-(CUSTOM TEXT)-HH(ORIGINAL FILE NUMBER).EXT This way I get a name with 6 numbers at the end; after that it's impossible to get back to the Original 4-digit File Number. This happen also every time the Original File

  • Help to find h.r program

    hallow experts did some now about program or bapi thet get from pa0001 to pa2010 program that u choose pernr and it bring u the number of hours that emp done . regards