Class SQL

java.lang.Object
net.sf.persism.SQL

public final class SQL extends Object
Simple wrapper for SQL String. Mainly to allow for overloads to fetch/query methods.
See Also:
  • Method Details

    • sql

      public static SQL sql(String sql)
      Method to instantiate a regular SQL string.
      
            Contact> contact;
            contact = session.fetch(Contact.class,
                      sql("SELECT * FROM CONTACTS WHERE LAST_NAME = ? AND FIRST_NAME = ?"),
                      params("Fred", "Flintstone");
       
      Parameters:
      sql - String
      Returns:
      new SQL object
    • where

      public static SQL where(String where)
      Method used to specify an SQL WHERE clause for an SQL Statement. The SELECT ... parts would be provided by Persism. Only here do we allow property names in the query
      
            List<Contact> contacts;
            contacts = session.query(Contact.class,
                       where("(:firstname = @name OR :company = @name) and :lastname = @last and :city = @city and :amountOwed > @owe ORDER BY :dateAdded"),
                       named(Map.of("name", "Fred", "last", "Flintstone", "owe", 10, "city", "Somewhere")));
       
      Parameters:
      where - String
      Returns:
      new SQL object
    • proc

      public static SQL proc(String storedProc)
      Static initializer for a new SQL stored procedure string.
      
            List<CustomerOrder> list;
            list = session.query(CustomerOrder.class, proc("[spCustomerOrders](?)"), params("123"));
       
      Parameters:
      storedProc - String
      Returns:
      new SQL object