1 Reply Latest reply: Mar 17, 2014 10:57 AM by chris_delahunt RSS

    Toplink - using parameters in the native sql


      Am new to Toplink and have this old application using Toplink which has native sql to read from the table without having any named parameters. This is causing a performance impact at the database level.

      Sample code:


      public Person getPersonById(Integer personID, DatabaseSession session) {

          ReadAllQuery query = new ReadAllQuery();



          String  sSQL = "SELECT * FROM Person where id = " + personID.toString();



           Vector  collection = (Vector)session.executeQuery(query);

           Person  person = (Person )collection.firstElement();





          return Person ;



      Am looking to convert the above code to use parameters such that database engine can cache it and don't have to compile the query everytime the above method is called.

      Any pointers on this would be of great great help!

      Thank You for your time and feedback, in advace.