forked from jkrasnay/sqlbuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialect.java
More file actions
48 lines (42 loc) · 1.48 KB
/
Dialect.java
File metadata and controls
48 lines (42 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package ca.krasnay.sqlbuilder;
import javax.sql.DataSource;
/**
* Interface representing a SQL dialect. Dialects can modify SQL queries in
* database server-specific ways.
*
* @author John Krasnay <john@krasnay.ca>
*/
public interface Dialect {
/**
* Returns a SQL statement that returns the number of rows that would be
* returned by another select.
*
* @param sql
* Inner select statement, i.e. the one that returns the rows
* themselves.
*/
public String createCountSelect(String sql);
/**
* Returns a SQL statement that returns a limited number of rows from an
* inner query. Note that the inner select should include an ORDER BY clause
* that strictly orders the result set; otherwise, some database servers may
* return pages inconsistently.
*
* @param sql
* Inner query that would return the full result set.
* @param limit
* Maximum number of rows to return.
* @param offset
* Index into the result set of the first row returned.
*/
public String createPageSelect(String sql, int limit, int offset);
/**
* Returns an integer supplier representing a database sequence.
*
* @param dataSource
* DataSource where the sequence exists.
* @param sequenceName
* Name of the sequence.
*/
public Supplier<Integer> getSequence(DataSource dataSource, String sequenceName);
}