Java 类org.hibernate.dialect.DB2Dialect 实例源码

项目:lams    文件:HibernateJpaVendorAdapter.java   
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
@SuppressWarnings("deprecation")
protected Class<?> determineDatabaseDialectClass(Database database) {
    switch (database) {
        case DB2: return DB2Dialect.class;
        case DERBY: return DerbyDialect.class;  // DerbyDialect deprecated in 4.x
        case H2: return H2Dialect.class;
        case HSQL: return HSQLDialect.class;
        case INFORMIX: return InformixDialect.class;
        case MYSQL: return MySQLDialect.class;
        case ORACLE: return Oracle9iDialect.class;
        case POSTGRESQL: return PostgreSQLDialect.class;  // PostgreSQLDialect deprecated in 4.x
        case SQL_SERVER: return SQLServerDialect.class;
        case SYBASE: return org.hibernate.dialect.SybaseDialect.class;  // SybaseDialect deprecated in 3.6 but not 4.x
        default: return null;
    }
}
项目:holon-datastore-jpa    文件:EntityManagerFactoryConfigurator.java   
private static Class<?> hibernateDatabaseDialectClass(DatabasePlatform database) {
    switch (database) {
    case DB2:
        return DB2Dialect.class;
    case DB2_AS400:
        return DB2400Dialect.class;
    case DERBY:
        return DerbyTenSevenDialect.class;
    case H2:
        return H2Dialect.class;
    case HSQL:
        return HSQLDialect.class;
    case INFORMIX:
        return InformixDialect.class;
    case MYSQL:
        return MySQL5Dialect.class;
    case ORACLE:
        return Oracle10gDialect.class;
    case POSTGRESQL:
        return PostgreSQL82Dialect.class;
    case SQL_SERVER:
        return SQLServerDialect.class;
    case MARIADB:
        return MySQL5Dialect.class;
    case HANA:
        return HANARowStoreDialect.class;
    case SQLITE:
    case NONE:
    default:
        break;
    }
    return null;
}
项目:spring4-understanding    文件:HibernateJpaVendorAdapter.java   
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
@SuppressWarnings("deprecation")
protected Class<?> determineDatabaseDialectClass(Database database) {
    switch (database) {
        case DB2: return DB2Dialect.class;
        case DERBY: return DerbyDialect.class;  // DerbyDialect deprecated in 4.x
        case H2: return H2Dialect.class;
        case HSQL: return HSQLDialect.class;
        case INFORMIX: return InformixDialect.class;
        case MYSQL: return MySQLDialect.class;
        case ORACLE: return Oracle9iDialect.class;
        case POSTGRESQL: return PostgreSQLDialect.class;  // PostgreSQLDialect deprecated in 4.x
        case SQL_SERVER: return SQLServerDialect.class;
        case SYBASE: return org.hibernate.dialect.SybaseDialect.class;  // SybaseDialect deprecated in 3.6 but not 4.x
        default: return null;
    }
}
项目:class-guard    文件:HibernateJpaVendorAdapter.java   
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or {@code null} if none found
 */
protected Class determineDatabaseDialectClass(Database database) {
    switch (database) {
        case DB2: return DB2Dialect.class;
        case DERBY: return DerbyDialect.class;
        case H2: return H2Dialect.class;
        case HSQL: return HSQLDialect.class;
        case INFORMIX: return InformixDialect.class;
        case MYSQL: return MySQLDialect.class;
        case ORACLE: return Oracle9iDialect.class;
        case POSTGRESQL: return PostgreSQLDialect.class;
        case SQL_SERVER: return SQLServerDialect.class;
        case SYBASE: return SybaseDialect.class;
        default: return null;
    }
}
项目:alfresco-repository    文件:ThumbnailServiceImplTest.java   
private boolean shouldTestBeSkippedForCurrentDB()
{
    Dialect dialect = (Dialect) applicationContext.getBean("dialect");
    return dialect instanceof AlfrescoOracle9Dialect 
            || dialect instanceof AlfrescoSQLServerDialect 
            || dialect instanceof DB2Dialect;
}
项目:alfresco-repository    文件:BaseNodeServiceTest.java   
public void testLargeStrings() throws Exception
{
    StringBuilder sb = new StringBuilder(2056);
    for (int i = 0; i < 1024; i++)
    {
        if (dialect instanceof DB2Dialect)
        {
            sb.append("A"); // pending ALF-4300
        }
        else
        {
            sb.append("\u1234");
        }
    }
    String longString = sb.toString();
    int len = longString.length();

    // Create a normal node
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
    // fill properties
    fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
    fillProperties(ASPECT_QNAME_TEST_TITLED, properties);

    // create node for real
    NodeRef nodeRef = nodeService.createNode(
            rootNodeRef,
            ASSOC_TYPE_QNAME_TEST_CHILDREN,
            QName.createQName("MyContent"),
            TYPE_QNAME_TEST_CONTENT,
            properties).getChildRef();

    // Modify name using the long string
    nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, longString);
}
项目:cacheonix-core    文件:ASTParserLoadingTest.java   
public void testStr() {
    Session session = openSession();
    Transaction txn = session.beginTransaction();
    Animal an = new Animal();
    an.setBodyWeight(123.45f);
    session.persist(an);
    String str = (String) session.createQuery("select str(an.bodyWeight) from Animal an where str(an.bodyWeight) like '123%' or str(an.bodyWeight) like '1.23%'").uniqueResult();
    if ( getDialect() instanceof DB2Dialect ) {
        assertTrue( str.startsWith("1.234") );
    }
    else if ( getDialect() instanceof SQLServerDialect ) {
        // no assertion as SQLServer always returns nulls here; even trying directly against the
        // database, it seems to have problems with str() in the where clause...
    }
    else {
        assertTrue( str.startsWith("123.4") );
    }
    if ( ! ( getDialect() instanceof SybaseDialect ) ) {
        // In TransactSQL (the variant spoken by Sybase and SQLServer), the str() function
        // is explicitly intended for numeric values only...
        String dateStr1 = (String) session.createQuery("select str(current_date) from Animal").uniqueResult();
        String dateStr2 = (String) session.createQuery("select str(year(current_date))||'-'||str(month(current_date))||'-'||str(day(current_date)) from Animal").uniqueResult();
        System.out.println(dateStr1 + '=' + dateStr2);
        if ( ! ( getDialect() instanceof Oracle9Dialect || getDialect() instanceof Oracle8iDialect ) ) { //Oracle renders the name of the month :(
            String[] dp1 = StringHelper.split("-", dateStr1);
            String[] dp2 = StringHelper.split("-", dateStr2);
            for (int i=0; i<3; i++) {
                if ( dp1[i].startsWith( "0" ) ) {
                    dp1[i] = dp1[i].substring( 1 );
                }
                assertEquals( dp1[i], dp2[i] );
            }
        }
    }
    session.delete(an);
    txn.commit();
    session.close();
}
项目:cacheonix-core    文件:ASTParserLoadingTest.java   
public void testCast() {
    if ( ( getDialect() instanceof MySQLDialect ) || ( getDialect() instanceof DB2Dialect ) ) {
        return;
    }
    Session session = openSession();
    Transaction txn = session.beginTransaction();
    session.createQuery("from Human h where h.nickName like 'G%'").list();
    session.createQuery("from Animal a where cast(a.bodyWeight as string) like '1.%'").list();
    session.createQuery("from Animal a where cast(a.bodyWeight as integer) = 1").list();
    txn.commit();
    session.close();
}
项目:cacheonix-core    文件:ASTParserLoadingTest.java   
public void testExtract() {
    Session session = openSession();
    Transaction txn = session.beginTransaction();
    session.createQuery("select second(current_timestamp()), minute(current_timestamp()), hour(current_timestamp()) from Mammal m").list();
    session.createQuery("select day(m.birthdate), month(m.birthdate), year(m.birthdate) from Mammal m").list();
    if ( !(getDialect() instanceof DB2Dialect) ) { //no ANSI extract
        session.createQuery("select extract(second from current_timestamp()), extract(minute from current_timestamp()), extract(hour from current_timestamp()) from Mammal m").list();
        session.createQuery("select extract(day from m.birthdate), extract(month from m.birthdate), extract(year from m.birthdate) from Mammal m").list();
    }
    txn.commit();
    session.close();
}
项目:cacheonix-core    文件:HQLTest.java   
public void testOrderBy() throws Exception {
    assertTranslation( "from Animal an order by an.bodyWeight" );
    assertTranslation( "from Animal an order by an.bodyWeight asc" );
    assertTranslation( "from Animal an order by an.bodyWeight desc" );
    assertTranslation( "from Animal an order by sqrt(an.bodyWeight*4)/2" );
    assertTranslation( "from Animal an order by an.mother.bodyWeight" );
    assertTranslation( "from Animal an order by an.bodyWeight, an.description" );
    assertTranslation( "from Animal an order by an.bodyWeight asc, an.description desc" );
    if ( getDialect() instanceof HSQLDialect || getDialect() instanceof DB2Dialect ) {
        assertTranslation( "from Human h order by sqrt(h.bodyWeight), year(h.birthdate)" );
    }
}
项目:community-edition-old    文件:BaseNodeServiceTest.java   
public void testLargeStrings() throws Exception
{
    StringBuilder sb = new StringBuilder(2056);
    for (int i = 0; i < 1024; i++)
    {
        if (dialect instanceof DB2Dialect)
        {
            sb.append("A"); // pending ALF-4300
        }
        else
        {
            sb.append("\u1234");
        }
    }
    String longString = sb.toString();
    int len = longString.length();

    // Create a normal node
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(5);
    // fill properties
    fillProperties(TYPE_QNAME_TEST_CONTENT, properties);
    fillProperties(ASPECT_QNAME_TEST_TITLED, properties);

    // create node for real
    NodeRef nodeRef = nodeService.createNode(
            rootNodeRef,
            ASSOC_TYPE_QNAME_TEST_CHILDREN,
            QName.createQName("MyContent"),
            TYPE_QNAME_TEST_CONTENT,
            properties).getChildRef();

    // Modify name using the long string
    nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, longString);
}
项目:kuali_rice    文件:DevHibernateJpaVendorAdapter.java   
/**
 * Determine the Hibernate database dialect class for the given target database.
 * @param database the target database
 * @return the Hibernate database dialect class, or <code>null<code> if none found
 */
protected Class determineDatabaseDialectClass(Database database) {
    switch (database) {
        case DB2: return DB2Dialect.class;
        case HSQL: return HSQLDialect.class;
        case INFORMIX: return InformixDialect.class;
        case MYSQL: return MySQLDialect.class;
        case ORACLE: return Oracle9iDialect.class;
        case POSTGRESQL: return PostgreSQLDialect.class;
        case SQL_SERVER: return SQLServerDialect.class;
        case SYBASE: return SybaseASE15Dialect.class;
        default: return null;
    }
}
项目:lams    文件:StrategySelectorBuilder.java   
private void addDialects(StrategySelectorImpl strategySelector) {
    addDialect( strategySelector, Cache71Dialect.class );
    addDialect( strategySelector, CUBRIDDialect.class );
    addDialect( strategySelector, DB2Dialect.class );
    addDialect( strategySelector, DB2390Dialect.class );
    addDialect( strategySelector, DB2400Dialect.class );
    addDialect( strategySelector, DerbyTenFiveDialect.class );
    addDialect( strategySelector, DerbyTenSixDialect.class );
    addDialect( strategySelector, DerbyTenSevenDialect.class );
    addDialect( strategySelector, FirebirdDialect.class );
    addDialect( strategySelector, FrontBaseDialect.class );
    addDialect( strategySelector, H2Dialect.class );
    addDialect( strategySelector, HSQLDialect.class );
    addDialect( strategySelector, InformixDialect.class );
    addDialect( strategySelector, IngresDialect.class );
    addDialect( strategySelector, Ingres9Dialect.class );
    addDialect( strategySelector, Ingres10Dialect.class );
    addDialect( strategySelector, InterbaseDialect.class );
    addDialect( strategySelector, JDataStoreDialect.class );
    addDialect( strategySelector, MckoiDialect.class );
    addDialect( strategySelector, MimerSQLDialect.class );
    addDialect( strategySelector, MySQL5Dialect.class );
    addDialect( strategySelector, MySQL5InnoDBDialect.class );
    addDialect( strategySelector, MySQL5Dialect.class );
    addDialect( strategySelector, MySQL5InnoDBDialect.class );
    addDialect( strategySelector, Oracle8iDialect.class );
    addDialect( strategySelector, Oracle9iDialect.class );
    addDialect( strategySelector, Oracle10gDialect.class );
    addDialect( strategySelector, PointbaseDialect.class );
    addDialect( strategySelector, PostgresPlusDialect.class );
    addDialect( strategySelector, PostgreSQL81Dialect.class );
    addDialect( strategySelector, PostgreSQL82Dialect.class );
    addDialect( strategySelector, PostgreSQL9Dialect.class );
    addDialect( strategySelector, ProgressDialect.class );
    addDialect( strategySelector, SAPDBDialect.class );
    addDialect( strategySelector, SQLServerDialect.class );
    addDialect( strategySelector, SQLServer2005Dialect.class );
    addDialect( strategySelector, SQLServer2008Dialect.class );
    addDialect( strategySelector, Sybase11Dialect.class );
    addDialect( strategySelector, SybaseAnywhereDialect.class );
    addDialect( strategySelector, SybaseASE15Dialect.class );
    addDialect( strategySelector, SybaseASE157Dialect.class );
    addDialect( strategySelector, TeradataDialect.class );
    addDialect( strategySelector, TimesTenDialect.class );
}
项目:cacheonix-core    文件:FooBarTest.java   
public void testQueryLockMode() throws Exception {

        Session s = openSession();
        Transaction tx = s.beginTransaction();
        Bar bar = new Bar();
        s.save(bar);
        s.flush();
        bar.setString("changed");
        Baz baz = new Baz();
        baz.setFoo(bar);
        s.save(baz);
        Query q = s.createQuery("from Foo foo, Bar bar");
        if ( !(getDialect() instanceof DB2Dialect) ) {
            q.setLockMode("bar", LockMode.UPGRADE);
        }
        Object[] result = (Object[]) q.uniqueResult();
        Object b = result[0];
        assertTrue( s.getCurrentLockMode(b)==LockMode.WRITE && s.getCurrentLockMode( result[1] )==LockMode.WRITE );
        tx.commit();
        s.disconnect();

        s.reconnect();
        tx = s.beginTransaction();
        assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
        s.find("from Foo foo");
        assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
        q = s.createQuery("from Foo foo");
        q.setLockMode("foo", LockMode.READ);
        q.list();
        assertTrue( s.getCurrentLockMode(b)==LockMode.READ);
        s.evict(baz);
        tx.commit();
        s.disconnect();

        s.reconnect();
        tx = s.beginTransaction();
        assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
        s.delete( s.load( Baz.class, baz.getCode() ) );
        assertTrue( s.getCurrentLockMode(b)==LockMode.NONE );
        tx.commit();
        s.close();

        s = openSession();
        tx = s.beginTransaction();
        q = s.createQuery("from Foo foo, Bar bar, Bar bar2");
        if ( !(getDialect() instanceof DB2Dialect) ) {
            q.setLockMode("bar", LockMode.UPGRADE);
        }
        q.setLockMode("bar2", LockMode.READ);
        result = (Object[]) q.list().get(0);
        if ( !(getDialect() instanceof DB2Dialect) ) {
            assertTrue( s.getCurrentLockMode( result[0] )==LockMode.UPGRADE && s.getCurrentLockMode( result[1] )==LockMode.UPGRADE );
        }
        s.delete( result[0] );
        tx.commit();
        s.close();
    }
项目:cacheonix-core    文件:FooBarTest.java   
public void testScrollableIterator() throws Exception {
    if ( getDialect() instanceof DB2Dialect || getDialect() instanceof OracleDialect || getDialect() instanceof SybaseDialect || getDialect() instanceof HSQLDialect ) {
        Session s = openSession();
        Transaction txn = s.beginTransaction();
        s.save( new Foo() );
        s.save( new Foo() );
        s.save( new Foo() );
        s.save( new Bar() );
        Query query = s.createQuery("select f, f.integer from Foo f");
        assertTrue( query.getReturnTypes().length==2 );
        ScrollableResults iter = query.scroll();
        assertTrue( iter.next() );
        assertTrue( iter.scroll(1) );
        FooProxy f2 = (FooProxy) iter.get()[0];
        assertTrue( f2!=null );
        assertTrue( iter.scroll(-1) );
        Object f1 = iter.get(0);
        iter.next();
        assertTrue( f1!=null && iter.get(0)==f2 );
        iter.getInteger(1);

        assertTrue( !iter.scroll(100) );
        assertTrue( iter.first() );
        assertTrue( iter.scroll(3) );
        Object f4 = iter.get(0);
        assertTrue( f4!=null );
        assertTrue( !iter.next() );
        assertTrue( iter.first() );
        assertTrue( iter.get(0)==f1 );
        assertTrue( iter.last() );
        assertTrue( iter.get(0)==f4 );
        assertTrue( iter.previous() );
        txn.commit();
        s.close();

        s = openSession();
        txn = s.beginTransaction();
        query = s.createQuery("select f, f.integer from Foo f");
        assertTrue( query.getReturnTypes().length==2 );
        iter = query.scroll();
        assertTrue( iter.next() );
        assertTrue( iter.scroll(1) );
        f2 = (FooProxy) iter.get()[0];
        assertTrue( f2!=null );
        assertTrue( f2.getString()!=null  && f2.getComponent().getImportantDates().length > 0 );
        assertTrue( iter.scroll(-1) );
        f1 = iter.get(0);
        iter.next();
        assertTrue( f1!=null && iter.get(0)==f2 );
        iter.getInteger(1);

        assertTrue( !iter.scroll(100) );
        assertTrue( iter.first() );
        assertTrue( iter.scroll(3) );
        f4 = iter.get(0);
        assertTrue( f4!=null );
        assertTrue( !iter.next() );
        assertTrue( iter.first() );
        assertTrue( iter.get(0)==f1 );
        assertTrue( iter.last() );
        assertTrue( iter.get(0)==f4 );
        assertTrue( iter.previous() );
        assertTrue( s.delete("from Foo")==4 );
        s.flush();
        assertTrue( s.find("from java.lang.Object").size()==0 );
        txn.commit();
        s.close();
    }
}
项目:cacheonix-core    文件:DB2CustomSQLTest.java   
public boolean appliesTo(Dialect dialect) {
    return ( dialect instanceof DB2Dialect);
}
项目:Portofino    文件:IbmDb2DatabasePlatform.java   
public IbmDb2DatabasePlatform() {
    super(new DB2Dialect(), "jdbc:db2://<host>[:<port>]/<database_name>");
}
项目:cacheonix-core    文件:FunctionalTestCase.java   
/**
 * Does the db/dialect support using a column's physical name in the order-by clause
 * even after it has been aliased in the select clause.  This is not actually
 * required by the SQL spec, although virtually ever DB in the world supports this
 * (the most glaring omission here being IBM-variant DBs ala DB2 and Derby).
 *
 * @param testDescription description of the scenario being tested.
 * @return true if is allowed
 */
protected boolean allowsPhysicalColumnNameInOrderby(String testDescription) {
    if ( DB2Dialect.class.isInstance( getDialect() ) ) {
        // https://issues.apache.org/jira/browse/DERBY-1624
        reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
        return false;
    }
    return true;
}
项目:cacheonix-core    文件:TestCase.java   
/**
 * Does the db/dialect support using a column's physical name in the order-by clause
 * even after it has been aliased in the select clause.  This is not actually
 * required by the SQL spec, although virtually ever DB in the world supports this
 * (the most glaring omission here being IBM-variant DBs ala DB2 and Derby).
 *
 * @param testDescription description of the scenario being tested.
 * @return true if is allowed
 */
protected boolean allowsPhysicalColumnNameInOrderby(String testDescription) {
    if ( DB2Dialect.class.isInstance( getDialect() ) ) {
        // https://issues.apache.org/jira/browse/DERBY-1624
        reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
        return false;
    }
    return true;
}