use of org.hibernate.dialect.Oracle9iDialect in project hibernate-orm by hibernate.
the class StandardDialectResolver method resolveDialect.
@Override
public Dialect resolveDialect(DialectResolutionInfo info) {
final String databaseName = info.getDatabaseName();
if ("CUBRID".equalsIgnoreCase(databaseName)) {
return new CUBRIDDialect();
}
if ("HSQL Database Engine".equals(databaseName)) {
return new HSQLDialect();
}
if ("H2".equals(databaseName)) {
return new H2Dialect();
}
if ("MySQL".equals(databaseName)) {
final int majorVersion = info.getDatabaseMajorVersion();
if (majorVersion >= 5) {
return new MySQL5Dialect();
}
return new MySQLDialect();
}
if ("PostgreSQL".equals(databaseName)) {
final int majorVersion = info.getDatabaseMajorVersion();
final int minorVersion = info.getDatabaseMinorVersion();
if (majorVersion == 9) {
if (minorVersion >= 4) {
return new PostgreSQL94Dialect();
} else if (minorVersion >= 2) {
return new PostgreSQL92Dialect();
}
return new PostgreSQL9Dialect();
}
if (majorVersion == 8 && minorVersion >= 2) {
return new PostgreSQL82Dialect();
}
return new PostgreSQL81Dialect();
}
if ("EnterpriseDB".equals(databaseName)) {
return new PostgresPlusDialect();
}
if ("Apache Derby".equals(databaseName)) {
final int majorVersion = info.getDatabaseMajorVersion();
final int minorVersion = info.getDatabaseMinorVersion();
if (majorVersion > 10 || (majorVersion == 10 && minorVersion >= 7)) {
return new DerbyTenSevenDialect();
} else if (majorVersion == 10 && minorVersion == 6) {
return new DerbyTenSixDialect();
} else if (majorVersion == 10 && minorVersion == 5) {
return new DerbyTenFiveDialect();
} else {
return new DerbyDialect();
}
}
if ("ingres".equalsIgnoreCase(databaseName)) {
final int majorVersion = info.getDatabaseMajorVersion();
final int minorVersion = info.getDatabaseMinorVersion();
switch(majorVersion) {
case 9:
if (minorVersion > 2) {
return new Ingres9Dialect();
}
return new IngresDialect();
case 10:
return new Ingres10Dialect();
default:
LOG.unknownIngresVersion(majorVersion);
}
return new IngresDialect();
}
if (databaseName.startsWith("Microsoft SQL Server")) {
final int majorVersion = info.getDatabaseMajorVersion();
switch(majorVersion) {
case 8:
{
return new SQLServerDialect();
}
case 9:
{
return new SQLServer2005Dialect();
}
case 10:
{
return new SQLServer2008Dialect();
}
case 11:
case 12:
case 13:
{
return new SQLServer2012Dialect();
}
default:
{
if (majorVersion < 8) {
LOG.unknownSqlServerVersion(majorVersion, SQLServerDialect.class);
return new SQLServerDialect();
} else {
// assume `majorVersion > 13`
LOG.unknownSqlServerVersion(majorVersion, SQLServer2012Dialect.class);
return new SQLServer2012Dialect();
}
}
}
}
if ("Sybase SQL Server".equals(databaseName) || "Adaptive Server Enterprise".equals(databaseName)) {
return new SybaseASE15Dialect();
}
if (databaseName.startsWith("Adaptive Server Anywhere")) {
return new SybaseAnywhereDialect();
}
if ("Informix Dynamic Server".equals(databaseName)) {
return new InformixDialect();
}
if ("DB2 UDB for AS/400".equals(databaseName)) {
return new DB2400Dialect();
}
if (databaseName.startsWith("DB2/")) {
return new DB2Dialect();
}
if ("Oracle".equals(databaseName)) {
final int majorVersion = info.getDatabaseMajorVersion();
switch(majorVersion) {
case 12:
return new Oracle12cDialect();
case 11:
// fall through
case 10:
return new Oracle10gDialect();
case 9:
return new Oracle9iDialect();
case 8:
return new Oracle8iDialect();
default:
LOG.unknownOracleVersion(majorVersion);
}
return new Oracle8iDialect();
}
if ("HDB".equals(databaseName)) {
// SAP recommends defaulting to column store.
return new HANAColumnStoreDialect();
}
if (databaseName.startsWith("Firebird")) {
return new FirebirdDialect();
}
return null;
}
use of org.hibernate.dialect.Oracle9iDialect in project hibernate-orm by hibernate.
the class SQLFunctionsTest method testDialectSQLFunctions.
@Test
public void testDialectSQLFunctions() throws Exception {
Session s = openSession();
Transaction t = s.beginTransaction();
Iterator iter = s.createQuery("select max(s.count) from Simple s").iterate();
if (getDialect() instanceof MySQLDialect)
assertTrue(iter.hasNext() && iter.next() == null);
Simple simple = new Simple(Long.valueOf(10));
simple.setName("Simple Dialect Function Test");
simple.setAddress("Simple Address");
simple.setPay(Float.valueOf(45.8f));
simple.setCount(2);
s.save(simple);
// Test to make sure allocating an specified object operates correctly.
assertTrue(s.createQuery("select new org.hibernate.test.legacy.S(s.count, s.address) from Simple s").list().size() == 1);
// Quick check the base dialect functions operate correctly
assertTrue(s.createQuery("select max(s.count) from Simple s").list().size() == 1);
assertTrue(s.createQuery("select count(*) from Simple s").list().size() == 1);
if (getDialect() instanceof Oracle9iDialect) {
// Check Oracle Dialect mix of dialect functions - no args (no parenthesis and single arg functions
List rset = s.createQuery("select s.name, sysdate, trunc(s.pay), round(s.pay) from Simple s").list();
assertNotNull("Name string should have been returned", (((Object[]) rset.get(0))[0]));
assertNotNull("Todays Date should have been returned", (((Object[]) rset.get(0))[1]));
assertEquals("trunc(45.8) result was incorrect ", Float.valueOf(45), ((Object[]) rset.get(0))[2]);
assertEquals("round(45.8) result was incorrect ", Float.valueOf(46), ((Object[]) rset.get(0))[3]);
simple.setPay(new Float(-45.8));
s.update(simple);
// Test type conversions while using nested functions (Float to Int).
rset = s.createQuery("select abs(round(s.pay)) from Simple s").list();
assertEquals("abs(round(-45.8)) result was incorrect ", Float.valueOf(46), rset.get(0));
// Test a larger depth 3 function example - Not a useful combo other than for testing
assertTrue(s.createQuery("select trunc(round(sysdate)) from Simple s").list().size() == 1);
// Test the oracle standard NVL funtion as a test of multi-param functions...
simple.setPay(null);
s.update(simple);
Integer value = (Integer) s.createQuery("select MOD( NVL(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0);
assertTrue(0 == value.intValue());
}
if ((getDialect() instanceof HSQLDialect)) {
// Test the hsql standard MOD funtion as a test of multi-param functions...
Integer value = (Integer) s.createQuery("select MOD(s.count, 2) from Simple as s where s.id = 10").list().get(0);
assertTrue(0 == value.intValue());
}
s.delete(simple);
t.commit();
s.close();
}
Aggregations