forked from OpenGamma/ElSql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,7 @@ public List<SqlFragment> getFragments() { | |
protected void toSQL(StringBuilder buf, ElSqlBundle bundle, SqlParameterSource paramSource) { | ||
for (SqlFragment fragment : _fragments) { | ||
fragment.toSQL(buf, bundle, paramSource); | ||
//buf.append("\n"); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ati-ozgur
Author
Owner
|
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,10 @@ public class ElSqlConfig { | |
* of FETCH-OFFSET. | ||
*/ | ||
public static final ElSqlConfig MYSQL = new MySqlElSqlConfig(); | ||
|
||
|
||
public static final ElSqlConfig ORACLE = new OracleElSqlConfig(); | ||
|
||
/** | ||
* A constant for the config needed for SQL Server 2008, which pages in a different way. | ||
*/ | ||
|
@@ -201,6 +205,32 @@ public String getPaging(int offset, int fetchLimit) { | |
} | ||
} | ||
|
||
|
||
private static class OracleElSqlConfig extends ElSqlConfig { | ||
public OracleElSqlConfig() { | ||
super("Oracle"); | ||
} | ||
@Override | ||
public String addPaging(String selectToPage, int offset, int fetchLimit) { | ||
if (fetchLimit == 0 && offset == 0) { | ||
return selectToPage; | ||
} | ||
if (offset == 0 && fetchLimit > 0) | ||
{ | ||
return "SELECT * FROM ( " + selectToPage + " ) where rownum <= " + fetchLimit; | ||
|
||
} | ||
int start = offset; | ||
int end = offset + fetchLimit; | ||
|
||
return "SELECT * FROM (SELECT row_.*,rownum rownum_ FROM ( " + selectToPage + " ) row_ where rownum <= "+ end +") WHERE rownum_ > " + start; | ||
} | ||
@Override | ||
public String getPaging(int offset, int fetchLimit) { | ||
throw new UnsupportedOperationException(); | ||
This comment has been minimized.
Sorry, something went wrong.
jodastephen
|
||
} | ||
} | ||
|
||
//------------------------------------------------------------------------- | ||
/** | ||
* Class for SQL server 2008. | ||
|
Did you comment this out for a reason?