java.lang.Object
net.sf.persism.SQL
Simple wrapper for SQL String. Mainly to allow for overloads to fetch/query methods.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionlimit(int limit) Specifies a limit to the query result which will translate to the specific SQL syntax when executed.static SQLStatic initializer for a new SQL stored procedure string.static SQLMethod to instantiate a regular SQL string.static SQLMethod used to specify an SQL WHERE clause for an SQL Statement.
-
Method Details
-
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
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 queryList<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
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
-
limit
Specifies a limit to the query result which will translate to the specific SQL syntax when executed.List<PublisherTitle> publisherTitles = session.query(PublisherTitle.class, where("1=1").limit(4));- Parameters:
limit- positive integer number- Returns:
- current SQL object
- Since:
- 2.3
-