当前位置: 首页>>代码示例>>Java>>正文


Java PostgreSQLDialect类代码示例

本文整理汇总了Java中org.hibernate.dialect.PostgreSQLDialect的典型用法代码示例。如果您正苦于以下问题:Java PostgreSQLDialect类的具体用法?Java PostgreSQLDialect怎么用?Java PostgreSQLDialect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PostgreSQLDialect类属于org.hibernate.dialect包,在下文中一共展示了PostgreSQLDialect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: canExecuteSpecificDialectScript

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
/**
 * Test the case of executing a specific (e.g. PostgreSQL) database script
 * when no general script is present (therefore no overriding mechanism is required).
 * 
 * @throws Exception 
 */
@Test
public void canExecuteSpecificDialectScript() throws Exception
{
    scriptExecutor.executeScriptUrl("scriptexec/${db.script.dialect}/specific.sql");
    
    String select = "select message from alf_test_script_exec_specific";
    List<String> res = jdbcTmpl.queryForList(select, String.class);
    assertEquals(1, res.size());
    if (dialect.getClass().equals(MySQLInnoDBDialect.class))
    {
        assertEquals("mysql", res.get(0));
    }
    else if (dialect.getClass().equals(PostgreSQLDialect.class))
    {
        assertEquals("postgresql", res.get(0));            
    }
    else
    {
        log.warn("No suitable dialect-specific DB script for test canExecuteSpecificDialectScript()");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:ScriptExecutorImplIntegrationTest.java

示例2: canExecuteSpecificDialectOverridingGenericScript

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
/**
 * Test the case of executing a specific database script (e.g. PostgreSQL) when
 * a more generic script also exists -- the more generic script is not run.
 * 
 * @throws Exception
 */
@Test
public void canExecuteSpecificDialectOverridingGenericScript() throws Exception
{
    scriptExecutor.executeScriptUrl("scriptexec/${db.script.dialect}/override.sql");
    
    String select = "select message from alf_test_script_exec_override";
    List<String> res = jdbcTmpl.queryForList(select, String.class);
    assertEquals(1, res.size());
    if (dialect.getClass().equals(MySQLInnoDBDialect.class))
    {
        assertEquals("mysql", res.get(0));
    }
    else if (dialect.getClass().equals(PostgreSQLDialect.class))
    {
        assertEquals("postgresql", res.get(0));            
    }
    else
    {
        log.warn("No suitable dialect-specific DB script for test canExecuteSpecificDialectOverridingGenericScript()");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:ScriptExecutorImplIntegrationTest.java

示例3: determineDatabaseDialectClass

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HibernateJpaVendorAdapter.java

示例4: getPostgresHbProps

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
private Properties getPostgresHbProps(Properties obProps) {
  isPostgresDatabase = true;
  final Properties props = new Properties();
  props.setProperty(Environment.DIALECT, PostgreSQLDialect.class.getName());
  if (isJNDIModeOn(obProps)) {
    setJNDI(obProps, props);
  } else {
    props.setProperty(Environment.DRIVER, "org.postgresql.Driver");
    props.setProperty(Environment.URL,
        obProps.getProperty("bbdd.url") + "/" + obProps.getProperty("bbdd.sid"));

    props.setProperty(Environment.USER, obProps.getProperty("bbdd.user"));
    props.setProperty(Environment.PASS, obProps.getProperty("bbdd.password"));
  }
  return props;
}
 
开发者ID:mauyr,项目名称:openbravo-brazil,代码行数:17,代码来源:SessionFactoryController.java

示例5: testExpressionWithParamInFunction

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
/**
 * Copied from {@link HQLTest#testExpressionWithParamInFunction}
 */
public void testExpressionWithParamInFunction() {
	Session s = openSession();
	s.beginTransaction();
	s.createQuery( "from Animal a where abs(a.bodyWeight-:param) < 2.0" ).setLong( "param", 1 ).list();
	s.createQuery( "from Animal a where abs(:param - a.bodyWeight) < 2.0" ).setLong( "param", 1 ).list();
	if ( ! ( getDialect() instanceof HSQLDialect ) ) {
		// HSQLDB does not like the abs(? - ?) syntax...
		s.createQuery( "from Animal where abs(:x - :y) < 2.0" ).setLong( "x", 1 ).setLong( "y", 1 ).list();
	}
	s.createQuery( "from Animal where lower(upper(:foo)) like 'f%'" ).setString( "foo", "foo" ).list();
	s.createQuery( "from Animal a where abs(abs(a.bodyWeight - 1.0 + :param) * abs(length('ffobar')-3)) = 3.0" ).setLong( "param", 1 ).list();
	s.createQuery( "from Animal where lower(upper('foo') || upper(:bar)) like 'f%'" ).setString( "bar", "xyz" ).list();
	if ( ! ( getDialect() instanceof PostgreSQLDialect || getDialect() instanceof MySQLDialect ) ) {
		s.createQuery( "from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0" ).setLong( "param", 1 ).list();
	}
	s.getTransaction().commit();
	s.close();
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:22,代码来源:ASTParserLoadingTest.java

示例6: testExpressionWithParamInFunction

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
public void testExpressionWithParamInFunction() {
	assertTranslation("from Animal a where abs(a.bodyWeight-:param) < 2.0");
	assertTranslation("from Animal a where abs(:param - a.bodyWeight) < 2.0");
	assertTranslation("from Animal where abs(:x - :y) < 2.0");
	assertTranslation("from Animal where lower(upper(:foo)) like 'f%'");
	if ( ! ( getDialect() instanceof SybaseDialect ) ) {
		// SybaseDialect maps the length function -> len; classic translator does not consider that *when nested*
		assertTranslation("from Animal a where abs(abs(a.bodyWeight - 1.0 + :param) * abs(length('ffobar')-3)) = 3.0");
	}
	if ( !( getDialect() instanceof MySQLDialect || getDialect() instanceof SybaseDialect ) ) {
		assertTranslation("from Animal where lower(upper('foo') || upper(:bar)) like 'f%'");
	}
	if ( getDialect() instanceof PostgreSQLDialect ) {
		return;
	}
	assertTranslation("from Animal where abs(cast(1 as float) - cast(:param as float)) = 1.0");
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:18,代码来源:HQLTest.java

示例7: determineDatabaseDialectClass

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
/**
 * 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;
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:HibernateJpaVendorAdapter.java

示例8: setUp

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
public void setUp() throws Exception
{
    dialect = (Dialect) ctx.getBean("dialect");
    if (dialect instanceof PostgreSQLDialect)
    {
        // Note: PostgreSQL does not support \u0000 char embedded in a string
        // http://archives.postgresql.org/pgsql-jdbc/2007-02/msg00115.php
        COMPLEX_LOCAL_NAME = COMPLEX_LOCAL_NAME_NO_U0000;
    }
    
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    transactionService = serviceRegistry.getTransactionService();
    dictionaryService = BaseNodeServiceTest.loadModel(ctx);
    nodeService = serviceRegistry.getNodeService();

    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();

    // get the indexer and searcher factory
    IndexerAndSearcher indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("indexerAndSearcherFactory");
    searcher = new SearcherComponent();
    searcher.setIndexerAndSearcherFactory(indexerAndSearcher);
    // create a test workspace
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName()
            + "_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
    // begin a transaction
    txn = transactionService.getUserTransaction();
    txn.begin();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:SearcherComponentTest.java

示例9: exportDb

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
@Test
public void exportDb() throws Exception
{
    Class dialectClass = dialect.getClass();
    
    if (logger.isDebugEnabled())
    {
        logger.debug("Using dialect class " + dialectClass.getName());
    }
    if (PostgreSQLDialect.class.isAssignableFrom(dialectClass))
    {
        exportTester = new PostgreSQLDialectExportTester(exporter, tx, jdbcTemplate);
    }
    else if (AlfrescoMariaDBDialect.class.isAssignableFrom(dialectClass))
    {
        exportTester = new AlfrescoMariaDBDialectExportTester(exporter, tx, jdbcTemplate);
    }
    else if (MySQLDialect.class.isAssignableFrom(dialectClass))
    {
        exportTester = new MySQLDialectExportTester(exporter, tx, jdbcTemplate);
    }
    
    if (exportTester != null)
    {
        // Run the DBMS specific tests.
        exportTester.runExportTest();
    }
    else
    {
        if (logger.isInfoEnabled())
        {
            logger.info("Unsupported dialect for this test " + dialectClass.getName());
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:ExportDbTest.java

示例10: toSqlString

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
@Override
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) {
	final Dialect dialect = criteriaQuery.getFactory().getDialect();
	final String[] columns = criteriaQuery.findColumns( propertyName, criteria );
	if ( columns.length != 1 ) {
		throw new HibernateException( "ilike may only be used with single-column properties" );
	}
	if ( dialect instanceof PostgreSQLDialect || dialect instanceof PostgreSQL81Dialect) {
		return columns[0] + " ilike ?";
	}
	else {
		return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?";
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:IlikeExpression.java

示例11: HibernateDatabaseConfigurationFactory

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
public HibernateDatabaseConfigurationFactory() {
    builtInConfigurations = new HashMap<String, DatabaseConfiguration>();
    builtInConfigurations.put(SQLServerDialect.class.getName(),
            new MSSQLServerDatabaseConfiguration());
    builtInConfigurations.put(Oracle10gDialect.class.getName(),
            new OracleDatabaseConfiguration());
    builtInConfigurations.put(PostgreSQLDialect.class.getName(),
            new PostgreSQLDatabaseConfiguration());
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:10,代码来源:HibernateDatabaseConfigurationFactory.java

示例12: toSqlString

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
	Dialect dialect = criteriaQuery.getFactory().getDialect();
	String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);
	if (columns.length!=1) throw new HibernateException("ilike may only be used with single-column properties");
	if ( dialect instanceof PostgreSQLDialect ) {
		return columns[0] + " ilike ?";
	}
	else {
		return dialect.getLowercaseFunction() + '(' + columns[0] + ") like ?";
	}

	//TODO: get SQL rendering out of this package!
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:15,代码来源:IlikeExpression.java

示例13: testGroupByFunction

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
public void testGroupByFunction() {
	if ( getDialect() instanceof Oracle9Dialect ) return;
	if ( getDialect() instanceof Oracle8iDialect ) return; // the new hiearchy...
	if ( getDialect() instanceof PostgreSQLDialect ) return;
	assertTranslation( "select count(*) from Human h group by year(h.birthdate)" );
	assertTranslation( "select count(*) from Human h group by trunc( sqrt(h.bodyWeight*4)/2 )" );
	assertTranslation( "select count(*) from Human h group by year(sysdate)" );
}
 
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:9,代码来源:HQLTest.java

示例14: testAddEscapedChild

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
/**
 * @throws Exception
 */
public void testAddEscapedChild() throws Exception
{
    String COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u0000\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
    if (dialect instanceof PostgreSQLDialect)
    {
        // Note: PostgreSQL does not support \u0000 char embedded in a string
        // http://archives.postgresql.org/pgsql-jdbc/2007-02/msg00115.php
        COMPLEX_LOCAL_NAME = "\u0020\u0060\u00ac\u00a6\u0021\"\u00a3\u0024\u0025\u005e\u0026\u002a\u0028\u0029\u002d\u005f\u003d\u002b\t\n\\\u005b\u005d\u007b\u007d\u003b\u0027\u0023\u003a\u0040\u007e\u002c\u002e\u002f\u003c\u003e\u003f\\u007c\u005f\u0078\u0054\u0036\u0035\u0041\u005f";
    }

    luceneFTS.pause();
    buildBaseIndex();
    runBaseTests();

    ADMLuceneIndexerImpl indexer = ADMLuceneIndexerImpl.getUpdateIndexer(rootNodeRef.getStoreRef(), "delta" + System.currentTimeMillis(), luceneConfig);
    indexer.setMaxAtomicTransformationTime(1000000);
    indexer.setNodeService(nodeService);
    // indexer.setLuceneIndexLock(luceneIndexLock);
    indexer.setDictionaryService(dictionaryService);
    indexer.setTenantService(tenantService);
    indexer.setFullTextSearchIndexer(luceneFTS);
    indexer.setContentService(contentService);
    indexer.setTransactionService(transactionService);

    ChildAssociationRef car = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}" + COMPLEX_LOCAL_NAME), testSuperType);
    indexer.createNode(car);

    indexer.commit();

    ADMLuceneSearcherImpl searcher = buildSearcher();
    ResultSet results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:" + ISO9075.encode(COMPLEX_LOCAL_NAME) + "\"", null);
    assertEquals(1, results.length());
    results.close();
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:38,代码来源:ADMLuceneTest.java

示例15: exportDb

import org.hibernate.dialect.PostgreSQLDialect; //导入依赖的package包/类
@Test
public void exportDb() throws Exception
{
    Class dialectClass = dialect.getClass();
    
    if (logger.isDebugEnabled())
    {
        logger.debug("Using dialect class " + dialectClass.getName());
    }
    
    if (PostgreSQLDialect.class.isAssignableFrom(dialectClass))
    {
        exportTester = new PostgreSQLDialectExportTester(exporter, tx, jdbcTemplate);
    }
    else if (MySQLDialect.class.isAssignableFrom(dialectClass))
    {
        exportTester = new MySQLDialectExportTester(exporter, tx, jdbcTemplate);
    }
    
    if (exportTester != null)
    {
        // Run the DBMS specific tests.
        exportTester.runExportTest();
    }
    else
    {
        if (logger.isInfoEnabled())
        {
            logger.info("Unsupported dialect for this test " + dialectClass.getName());
        }
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:33,代码来源:ExportDbTest.java


注:本文中的org.hibernate.dialect.PostgreSQLDialect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。