org.hibernate.dialect.PostgreSQL81Dialect Java Examples
The following examples show how to use
org.hibernate.dialect.PostgreSQL81Dialect.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SingleTableDiscriminatorFormulaTest.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 5 votes |
@Test @RequiresDialect({PostgreSQL81Dialect.class}) public void test() { doInJPA( this::entityManagerFactory, entityManager -> { DebitAccount debitAccount = new DebitAccount( "123-debit" ); debitAccount.setId( 1L ); debitAccount.setOwner( "John Doe" ); debitAccount.setBalance( BigDecimal.valueOf( 100 ) ); debitAccount.setInterestRate( BigDecimal.valueOf( 1.5d ) ); debitAccount.setOverdraftFee( BigDecimal.valueOf( 25 ) ); CreditAccount creditAccount = new CreditAccount( "456-credit" ); creditAccount.setId( 2L ); creditAccount.setOwner( "John Doe" ); creditAccount.setBalance( BigDecimal.valueOf( 1000 ) ); creditAccount.setInterestRate( BigDecimal.valueOf( 1.9d ) ); creditAccount.setCreditLimit( BigDecimal.valueOf( 5000 ) ); entityManager.persist( debitAccount ); entityManager.persist( creditAccount ); } ); doInJPA( this::entityManagerFactory, entityManager -> { List<Account> accounts = entityManager.createQuery( "select a from Account a" ).getResultList(); Assert.assertEquals( 2, accounts.size() ); } ); }
Example #2
Source File: SchemaGenerationTest.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected String[] getMappings() { if ( PostgreSQL81Dialect.class.isAssignableFrom( getDialect().getClass() ) ) { return new String[] { "org/hibernate/userguide/schema/SchemaGenerationTest.hbm.xml" }; } return super.getMappings(); }
Example #3
Source File: IlikeExpression.java From lams with GNU General Public License v2.0 | 5 votes |
@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 ?"; } }
Example #4
Source File: EngineDecorator.java From jpa2ddl with Apache License 2.0 | 5 votes |
public static EngineDecorator getEngineDecorator(String dialect) throws ClassNotFoundException { Class<?> dialectClass = Class.forName(dialect); if (MySQLDialect.class.isAssignableFrom(dialectClass)) { return new MySQLDecorator(); } else if (PostgreSQL81Dialect.class.isAssignableFrom(dialectClass)) { return new PostgreSQLDecorator(); } else if (Oracle8iDialect.class.isAssignableFrom(dialectClass)) { return new OracleDecorator(); } else if (SQLServerDialect.class.isAssignableFrom(dialectClass)) { return new SQLServerDecorator(); } return new NoOpDecorator(); }
Example #5
Source File: ReactiveAbstractEntityPersister.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
/** * Perform an SQL INSERT, and then retrieve a generated identifier. * <p> * This form is used for PostInsertIdentifierGenerator-style ids (IDENTITY, * select, etc). */ default CompletionStage<Serializable> insertReactive( Object[] fields, boolean[] notNull, String sql, Object object, SharedSessionContractImplementor session) throws HibernateException { if ( log.isTraceEnabled() ) { log.tracev( "Inserting entity: {0}", infoString(delegate()) ); if ( delegate().isVersioned() ) { log.tracev( "Version: {0}", Versioning.getVersion( fields, delegate()) ); } } Object[] params = PreparedStatementAdaptor.bind( insert -> { boolean[][] insertable = delegate().getPropertyColumnInsertable(); delegate().dehydrate( null, fields, notNull, insertable, 0, insert, session, false ); } ); SessionFactoryImplementor factory = session.getFactory(); Dialect dialect = factory.getJdbcServices().getDialect(); String identifierColumnName = delegate().getIdentifierColumnNames()[0]; ReactiveConnection connection = getReactiveConnection(session); if ( factory.getSessionFactoryOptions().isGetGeneratedKeysEnabled() ) { //TODO: wooooo this is awful ... I believe the problem is fixed in Hibernate 6 if ( dialect instanceof PostgreSQL81Dialect) { sql = sql + " returning " + identifierColumnName; } return connection.updateReturning( sql, params ).thenApply( id -> id ); } else { //use an extra round trip to fetch the id String selectIdSql = dialect.getIdentityColumnSupport() .getIdentitySelectString( delegate().getTableName(), identifierColumnName, Types.INTEGER ); return connection.update( sql, params ) .thenCompose( v -> connection.selectLong( selectIdSql, new Object[0] ) ) .thenApply( id -> id ); } }
Example #6
Source File: SchemaGenerationTest.java From google-cloud-spanner-hibernate with GNU Lesser General Public License v2.1 | 4 votes |
@Test @RequiresDialect( PostgreSQL81Dialect.class ) public void testPostgres() { }
Example #7
Source File: StrategySelectorBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
private void addDialects(StrategySelectorImpl strategySelector) { addDialect( strategySelector, Cache71Dialect.class ); addDialect( strategySelector, CUBRIDDialect.class ); addDialect( strategySelector, DB2Dialect.class ); addDialect( strategySelector, DB2390Dialect.class ); addDialect( strategySelector, DB2390V8Dialect.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, HANAColumnStoreDialect.class ); addDialect( strategySelector, HANARowStoreDialect.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, MySQL57InnoDBDialect.class ); addDialect( strategySelector, MySQL57Dialect.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 ); }