HHH-12856 Cleanup DB2400Dialect
This commit is contained in:
parent
1c3b8a1c28
commit
4aea43bdb0
|
@ -28,7 +28,7 @@ import org.hibernate.dialect.Cache71Dialect;
|
|||
import org.hibernate.dialect.DB2390Dialect;
|
||||
import org.hibernate.dialect.DB2390V8Dialect;
|
||||
import org.hibernate.dialect.DB2400Dialect;
|
||||
import org.hibernate.dialect.DB2400V7R1Dialect;
|
||||
import org.hibernate.dialect.DB2400V7R3Dialect;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
import org.hibernate.dialect.DerbyTenFiveDialect;
|
||||
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||
|
@ -203,7 +203,7 @@ public class StrategySelectorBuilder {
|
|||
addDialect( strategySelector, DB2390Dialect.class );
|
||||
addDialect( strategySelector, DB2390V8Dialect.class );
|
||||
addDialect( strategySelector, DB2400Dialect.class );
|
||||
addDialect( strategySelector, DB2400V7R1Dialect.class );
|
||||
addDialect( strategySelector, DB2400V7R3Dialect.class );
|
||||
addDialect( strategySelector, DerbyTenFiveDialect.class );
|
||||
addDialect( strategySelector, DerbyTenSixDialect.class );
|
||||
addDialect( strategySelector, DerbyTenSevenDialect.class );
|
||||
|
|
|
@ -21,81 +21,16 @@ import org.hibernate.engine.spi.RowSelection;
|
|||
*/
|
||||
public class DB2400Dialect extends DB2Dialect {
|
||||
|
||||
private static final AbstractLimitHandler LIMIT_HANDLER = new AbstractLimitHandler() {
|
||||
@Override
|
||||
public String processSql(String sql, RowSelection selection) {
|
||||
if ( LimitHelper.hasFirstRow( selection ) ) {
|
||||
//nest the main query in an outer select
|
||||
return "select * from ( select inner2_.*, rownumber() over(order by order of inner2_) as rownumber_ from ( "
|
||||
+ sql + " fetch first " + getMaxOrLimit( selection ) + " rows only ) as inner2_ ) as inner1_ where rownumber_ > "
|
||||
+ selection.getFirstRow() + " order by rownumber_";
|
||||
}
|
||||
return sql + " fetch first " + getMaxOrLimit( selection ) + " rows only";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLimit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useMaxForLimit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsVariableLimit() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean supportsSequences() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsLimit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuerySequencesString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean supportsLimitOffset() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useMaxForLimit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsVariableLimit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLimitString(String sql, int offset, int limit) {
|
||||
if ( offset > 0 ) {
|
||||
throw new UnsupportedOperationException( "query result offset is not supported" );
|
||||
}
|
||||
if ( limit == 0 ) {
|
||||
return sql;
|
||||
}
|
||||
return sql + " fetch first " + limit + " rows only ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public LimitHandler getLimitHandler() {
|
||||
return LIMIT_HANDLER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getForUpdateString() {
|
||||
return " for update with rs";
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
import org.hibernate.dialect.identity.DB2IdentityColumnSupport;
|
||||
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||
import org.hibernate.dialect.unique.DefaultUniqueDelegate;
|
||||
import org.hibernate.dialect.unique.UniqueDelegate;
|
||||
|
||||
|
@ -15,11 +17,11 @@ import org.hibernate.dialect.unique.UniqueDelegate;
|
|||
*
|
||||
* @author Pierrick Rouxel (pierrickrouxel)
|
||||
*/
|
||||
public class DB2400V7R1Dialect extends DB2Dialect {
|
||||
public class DB2400V7R3Dialect extends DB2400Dialect {
|
||||
|
||||
private final UniqueDelegate uniqueDelegate;
|
||||
|
||||
public DB2400V7R1Dialect() {
|
||||
public DB2400V7R3Dialect() {
|
||||
super();
|
||||
|
||||
uniqueDelegate = new DefaultUniqueDelegate(this);
|
||||
|
@ -31,12 +33,17 @@ public class DB2400V7R1Dialect extends DB2Dialect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getForUpdateString() {
|
||||
return " for update with rs";
|
||||
public boolean supportsSequences() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuerySequencesString() {
|
||||
return "select seqname from qsys2.syssequences";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||
return new DB2IdentityColumnSupport();
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ public enum Database {
|
|||
DB2 {
|
||||
@Override
|
||||
public Class<? extends Dialect> latestDialect() {
|
||||
return DB2400V7R1Dialect.class;
|
||||
return DB2400Dialect.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,15 +55,7 @@ public enum Database {
|
|||
final String databaseName = info.getDatabaseName();
|
||||
|
||||
if ( "DB2 UDB for AS/400".equals( databaseName ) ) {
|
||||
final int majorVersion = info.getDatabaseMajorVersion();
|
||||
final int minorVersion = info.getDatabaseMinorVersion();
|
||||
|
||||
if ( majorVersion > 7 || ( majorVersion == 7 && minorVersion >= 1 ) ) {
|
||||
return latestDialectInstance( this );
|
||||
}
|
||||
else {
|
||||
return new DB2400Dialect();
|
||||
}
|
||||
return new DB2400Dialect();
|
||||
}
|
||||
|
||||
if ( databaseName.startsWith( "DB2/" ) ) {
|
||||
|
|
|
@ -153,7 +153,6 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
|||
testDetermination( "DB2/LINUX390", DB2Dialect.class, resolver );
|
||||
testDetermination( "DB2/AIX64", DB2Dialect.class, resolver );
|
||||
testDetermination( "DB2 UDB for AS/400", DB2400Dialect.class, resolver );
|
||||
testDetermination( "DB2 UDB for AS/400", 7, 1, DB2400V7R1Dialect.class, resolver );
|
||||
testDetermination( "Oracle", 8, Oracle8iDialect.class, resolver );
|
||||
testDetermination( "Oracle", 9, Oracle9iDialect.class, resolver );
|
||||
testDetermination( "Oracle", 10, Oracle10gDialect.class, resolver );
|
||||
|
|
Loading…
Reference in New Issue