[OPENJPA-2598] Applying provided patch

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1806888 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Francesco Chicchiriccò 2017-09-01 06:38:48 +00:00
parent 2898b4e342
commit 778e8e9449
1 changed files with 22 additions and 1 deletions

View File

@ -72,7 +72,7 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
String driverName = meta.getDriverName();
String url = meta.getURL();
if (driverVendor == null) {
// serverMajorVersion of 8==2000, 9==2005, 10==2008
// serverMajorVersion of 8==2000, 9==2005, 10==2008, 11==2012
if (meta.getDatabaseMajorVersion() >= 9)
setSupportsXMLColumn(true);
if (meta.getDatabaseMajorVersion() >= 10) {
@ -83,6 +83,12 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
timestampTypeName = "DATETIME2";
datePrecision = MICRO / 10;
}
if (meta.getDatabaseMajorVersion() >= 11) {
//SQLServer 2012 supports range select
rangePosition = RANGE_POST_SELECT;
supportsSelectStartIndex = true;
supportsSelectEndIndex = true;
}
if (driverName != null) {
if (driverName.startsWith("Microsoft SQL Server")) {
// v1.1, 1.2, 2.0 or 3.0 driver
@ -342,4 +348,19 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
}
buf.append(")");
}
@Override
protected void appendSelectRange(SQLBuffer buf, long start, long end, boolean subselect) {
//SQL Server 2012 supports range select
if (this.getMajorVersion() >= 11) {
//we need an order by clause....
if (!buf.getSQL().contains(" ORDER BY ")) {
buf.append(" ORDER BY 1 ");
}
buf.append(" OFFSET ").append(Long.toString(start)).append(" ROWS ").
append(" FETCH NEXT ").append(Long.toString(end - start)).append(" ROWS ONLY ");
} else {
super.appendSelectRange(buf, start, end, subselect);
}
}
}