HHH-6866 Removing commented out code and formatting. No functional changes.
This commit is contained in:
parent
2e0e130cbe
commit
65b3e768fa
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import java.sql.CallableStatement;
|
import java.sql.CallableStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -38,6 +39,7 @@ import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SQL dialect for DB2.
|
* An SQL dialect for DB2.
|
||||||
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class DB2Dialect extends Dialect {
|
public class DB2Dialect extends Dialect {
|
||||||
|
@ -99,7 +101,10 @@ public class DB2Dialect extends Dialect {
|
||||||
|
|
||||||
registerFunction( "julian_day", new StandardSQLFunction( "julian_day", StandardBasicTypes.INTEGER ) );
|
registerFunction( "julian_day", new StandardSQLFunction( "julian_day", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction( "microsecond", new StandardSQLFunction( "microsecond", StandardBasicTypes.INTEGER ) );
|
registerFunction( "microsecond", new StandardSQLFunction( "microsecond", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction("midnight_seconds", new StandardSQLFunction("midnight_seconds", StandardBasicTypes.INTEGER) );
|
registerFunction(
|
||||||
|
"midnight_seconds",
|
||||||
|
new StandardSQLFunction( "midnight_seconds", StandardBasicTypes.INTEGER )
|
||||||
|
);
|
||||||
registerFunction( "minute", new StandardSQLFunction( "minute", StandardBasicTypes.INTEGER ) );
|
registerFunction( "minute", new StandardSQLFunction( "minute", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction( "month", new StandardSQLFunction( "month", StandardBasicTypes.INTEGER ) );
|
registerFunction( "month", new StandardSQLFunction( "month", StandardBasicTypes.INTEGER ) );
|
||||||
registerFunction( "monthname", new StandardSQLFunction( "monthname", StandardBasicTypes.STRING ) );
|
registerFunction( "monthname", new StandardSQLFunction( "monthname", StandardBasicTypes.STRING ) );
|
||||||
|
@ -116,7 +121,10 @@ public class DB2Dialect extends Dialect {
|
||||||
registerFunction( "days", new StandardSQLFunction( "days", StandardBasicTypes.LONG ) );
|
registerFunction( "days", new StandardSQLFunction( "days", StandardBasicTypes.LONG ) );
|
||||||
registerFunction( "current_time", new NoArgSQLFunction( "current time", StandardBasicTypes.TIME, false ) );
|
registerFunction( "current_time", new NoArgSQLFunction( "current time", StandardBasicTypes.TIME, false ) );
|
||||||
registerFunction( "time", new StandardSQLFunction( "time", StandardBasicTypes.TIME ) );
|
registerFunction( "time", new StandardSQLFunction( "time", StandardBasicTypes.TIME ) );
|
||||||
registerFunction("current_timestamp", new NoArgSQLFunction("current timestamp", StandardBasicTypes.TIMESTAMP, false) );
|
registerFunction(
|
||||||
|
"current_timestamp",
|
||||||
|
new NoArgSQLFunction( "current timestamp", StandardBasicTypes.TIMESTAMP, false )
|
||||||
|
);
|
||||||
registerFunction( "timestamp", new StandardSQLFunction( "timestamp", StandardBasicTypes.TIMESTAMP ) );
|
registerFunction( "timestamp", new StandardSQLFunction( "timestamp", StandardBasicTypes.TIMESTAMP ) );
|
||||||
registerFunction( "timestamp_iso", new StandardSQLFunction( "timestamp_iso", StandardBasicTypes.TIMESTAMP ) );
|
registerFunction( "timestamp_iso", new StandardSQLFunction( "timestamp_iso", StandardBasicTypes.TIMESTAMP ) );
|
||||||
registerFunction( "week", new StandardSQLFunction( "week", StandardBasicTypes.INTEGER ) );
|
registerFunction( "week", new StandardSQLFunction( "week", StandardBasicTypes.INTEGER ) );
|
||||||
|
@ -169,18 +177,23 @@ public class DB2Dialect extends Dialect {
|
||||||
public String getAddColumnString() {
|
public String getAddColumnString() {
|
||||||
return "add column";
|
return "add column";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean dropConstraints() {
|
public boolean dropConstraints() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsIdentityColumns() {
|
public boolean supportsIdentityColumns() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentitySelectString() {
|
public String getIdentitySelectString() {
|
||||||
return "values identity_val_local()";
|
return "values identity_val_local()";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentityColumnString() {
|
public String getIdentityColumnString() {
|
||||||
return "generated by default as identity"; //not null ... (start with 1) is implicit
|
return "generated by default as identity"; //not null ... (start with 1) is implicit
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentityInsertString() {
|
public String getIdentityInsertString() {
|
||||||
return "default";
|
return "default";
|
||||||
}
|
}
|
||||||
|
@ -188,9 +201,11 @@ public class DB2Dialect extends Dialect {
|
||||||
public String getSequenceNextValString(String sequenceName) {
|
public String getSequenceNextValString(String sequenceName) {
|
||||||
return "values nextval for " + sequenceName;
|
return "values nextval for " + sequenceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCreateSequenceString(String sequenceName) {
|
public String getCreateSequenceString(String sequenceName) {
|
||||||
return "create sequence " + sequenceName;
|
return "create sequence " + sequenceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDropSequenceString(String sequenceName) {
|
public String getDropSequenceString(String sequenceName) {
|
||||||
return "drop sequence " + sequenceName + " restrict";
|
return "drop sequence " + sequenceName + " restrict";
|
||||||
}
|
}
|
||||||
|
@ -210,58 +225,11 @@ public class DB2Dialect extends Dialect {
|
||||||
public boolean supportsLimit() {
|
public boolean supportsLimit() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsVariableLimit() {
|
public boolean supportsVariableLimit() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Render the <tt>rownumber() over ( .... ) as rownumber_,</tt>
|
|
||||||
// * bit, that goes in the select list
|
|
||||||
// */
|
|
||||||
// private String getRowNumber(String sql) {
|
|
||||||
// StringBuffer rownumber = new StringBuffer(50)
|
|
||||||
// .append("rownumber() over(");
|
|
||||||
//
|
|
||||||
// int orderByIndex = sql.toLowerCase().indexOf("order by");
|
|
||||||
//
|
|
||||||
// if ( orderByIndex>0 && !hasDistinct(sql) ) {
|
|
||||||
// rownumber.append( sql.substring(orderByIndex) );
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// rownumber.append(") as rownumber_,");
|
|
||||||
//
|
|
||||||
// return rownumber.toString();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getLimitString(String sql, boolean hasOffset) {
|
|
||||||
// int startOfSelect = sql.toLowerCase().indexOf("select");
|
|
||||||
//
|
|
||||||
// StringBuffer pagingSelect = new StringBuffer( sql.length()+100 )
|
|
||||||
// .append( sql.substring(0, startOfSelect) ) // add the comment
|
|
||||||
// .append("select * from ( select ") // nest the main query in an outer select
|
|
||||||
// .append( getRowNumber(sql) ); // add the rownnumber bit into the outer query select list
|
|
||||||
//
|
|
||||||
// if ( hasDistinct(sql) ) {
|
|
||||||
// pagingSelect.append(" row_.* from ( ") // add another (inner) nested select
|
|
||||||
// .append( sql.substring(startOfSelect) ) // add the main query
|
|
||||||
// .append(" ) as row_"); // close off the inner nested select
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// pagingSelect.append( sql.substring( startOfSelect + 6 ) ); // add the main query
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// pagingSelect.append(" ) as temp_ where rownumber_ ");
|
|
||||||
//
|
|
||||||
// //add the restriction to the outer select
|
|
||||||
// if (hasOffset) {
|
|
||||||
// pagingSelect.append("between ?+1 and ?");
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// pagingSelect.append("<= ?");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return pagingSelect.toString();
|
|
||||||
// }
|
|
||||||
public String getLimitString(String sql, int offset, int limit) {
|
public String getLimitString(String sql, int offset, int limit) {
|
||||||
if ( offset == 0 ) {
|
if ( offset == 0 ) {
|
||||||
return sql + " fetch first " + limit + " rows only";
|
return sql + " fetch first " + limit + " rows only";
|
||||||
|
@ -290,10 +258,6 @@ public String getLimitString(String sql, int offset, int limit) {
|
||||||
public int convertToFirstRowValue(int zeroBasedFirstResult) {
|
public int convertToFirstRowValue(int zeroBasedFirstResult) {
|
||||||
return zeroBasedFirstResult;
|
return zeroBasedFirstResult;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// private static boolean hasDistinct(String sql) {
|
|
||||||
// return sql.toLowerCase().indexOf("select distinct")>=0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getForUpdateString() {
|
public String getForUpdateString() {
|
||||||
return " for read only with rs";
|
return " for read only with rs";
|
||||||
|
@ -340,8 +304,20 @@ public String getLimitString(String sql, int offset, int limit) {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println( new DB2Dialect().getLimitString( "/*foo*/ select * from foos", true ) );
|
System.out.println( new DB2Dialect().getLimitString( "/*foo*/ select * from foos", true ) );
|
||||||
System.out.println( new DB2Dialect().getLimitString( "/*foo*/ select distinct * from foos", true ) );
|
System.out.println( new DB2Dialect().getLimitString( "/*foo*/ select distinct * from foos", true ) );
|
||||||
System.out.println( new DB2Dialect().getLimitString("/*foo*/ select * from foos foo order by foo.bar, foo.baz", true) );
|
System.out
|
||||||
System.out.println( new DB2Dialect().getLimitString("/*foo*/ select distinct * from foos foo order by foo.bar, foo.baz", true) );
|
.println(
|
||||||
|
new DB2Dialect().getLimitString(
|
||||||
|
"/*foo*/ select * from foos foo order by foo.bar, foo.baz",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
System.out
|
||||||
|
.println(
|
||||||
|
new DB2Dialect().getLimitString(
|
||||||
|
"/*foo*/ select distinct * from foos foo order by foo.bar, foo.baz",
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean supportsUnionAll() {
|
public boolean supportsUnionAll() {
|
||||||
|
|
Loading…
Reference in New Issue