protected void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { if ( value == null ) { st.setNull( index, sqlTypes( null )[0] ); } else { byte[] toSet = unWrap( value ); final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob(); if ( useInputStream ) { st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.length ); } else { st.setBlob( index, Hibernate.getLobCreator( session ).createBlob( toSet ) ); } } }
public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException { if ( value != null ) { byte[] toSet; toSet = toBytes( value ); if ( session.getFactory().getDialect().useInputStreamToInsertBlob() ) { st.setBinaryStream( index, new ByteArrayInputStream( toSet ), toSet.length ); } else { st.setBlob( index, Hibernate.getLobCreator( session ).createBlob( toSet ) ); } } else { st.setNull( index, sqlTypes( null )[0] ); } }
protected final Dialect getDialect() { return getFactory().getDialect(); }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { SessionFactoryImplementor factory = criteriaQuery.getFactory(); String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, this.propertyName); Dialect dialect = factory.getDialect(); if (dialect instanceof SpatialDialect) { SpatialDialect seDialect = (SpatialDialect) dialect; return seDialect.getSpatialFilterExpression(columns[0]); } else throw new IllegalStateException( "Dialect must be spatially enabled dialect"); }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { if ( criteriaQuery.getFactory().getDialect() instanceof MySQLDialect ) { return "not (" + criterion.toSqlString(criteria, criteriaQuery) + ')'; } else { return "not " + criterion.toSqlString(criteria, criteriaQuery); } }
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException { if ( criteriaQuery.getFactory().getDialect() instanceof MySQLDialect ) { return "not (" + criterion.toSqlString(criteria, criteriaQuery) + ')'; } else { return "not " + criterion.toSqlString(criteria, criteriaQuery); } }
public Object seed(SessionImplementor session) { if ( session == null ) { log.trace( "incoming session was null; using current jvm time" ); return super.seed( session ); } else if ( !session.getFactory().getDialect().supportsCurrentTimestampSelection() ) { log.debug( "falling back to vm-based timestamp, as dialect does not support current timestamp selection" ); return super.seed( session ); } else { return getCurrentTimestamp( session ); } }
private void createLoaders() { loaders.put( LockMode.NONE, createEntityLoader( LockMode.NONE ) ); UniqueEntityLoader readLoader = createEntityLoader( LockMode.READ ); loaders.put( LockMode.READ, readLoader ); //TODO: inexact, what we really need to know is: are any outer joins used? boolean disableForUpdate = getSubclassTableSpan() > 1 && hasSubclasses() && !getFactory().getDialect().supportsOuterJoinForUpdate(); loaders.put( LockMode.UPGRADE, disableForUpdate ? readLoader : createEntityLoader( LockMode.UPGRADE ) ); loaders.put( LockMode.UPGRADE_NOWAIT, disableForUpdate ? readLoader : createEntityLoader( LockMode.UPGRADE_NOWAIT ) ); }
private CaseFragment discriminatorFragment(String alias) { CaseFragment cases = getFactory().getDialect().createCaseFragment(); for ( int i=0; i<discriminatorValues.length; i++ ) { cases.addWhenColumnNotNull( generateTableAlias( alias, notNullColumnTableNumbers[i] ), notNullColumnNames[i], discriminatorValues[i] ); } return cases; }
public static SpatialDialect getSpatialDialect(CriteriaQuery criteriaQuery, SpatialFunction function) { Dialect dialect = criteriaQuery.getFactory().getDialect(); if (!(dialect instanceof SpatialDialect)) { throw new HibernateException("A spatial expression requires a spatial dialect."); } SpatialDialect spatialDialect = (SpatialDialect) dialect; if (!spatialDialect.supports(function)) { throw new HibernateException(function + " function not supported by this dialect"); } return spatialDialect; }
public void processBoolean(AST constant) { // TODO: something much better - look at the type of the other expression! // TODO: Have comparisonExpression and/or arithmeticExpression rules complete the resolution of boolean nodes. String replacement = ( String ) walker.getTokenReplacements().get( constant.getText() ); if ( replacement != null ) { constant.setText( replacement ); } else { boolean bool = "true".equals( constant.getText().toLowerCase() ); Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect(); constant.setText( dialect.toBooleanValueString(bool) ); } }
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 MySQLDialect) { return columns[0] + " rlike ?"; } if (isOracleDialect(dialect)) { return " REGEXP_LIKE (" + columns[0] + ", ?)"; } return columns[0] + " like ?"; }
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! }
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! }
private Timestamp getCurrentTimestamp(SessionImplementor session) { Dialect dialect = session.getFactory().getDialect(); String timestampSelectString = dialect.getCurrentTimestampSelectString(); if ( dialect.isCurrentTimestampSelectStringCallable() ) { return useCallableStatement( timestampSelectString, session ); } else { return usePreparedStatement( timestampSelectString, session ); } }
public OneToManyPersister(Collection collection, CacheConcurrencyStrategy cache, Configuration cfg, SessionFactoryImplementor factory) throws MappingException, CacheException { super( collection, cache, cfg, factory ); cascadeDeleteEnabled = collection.getKey().isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete(); keyIsNullable = collection.getKey().isNullable(); keyIsUpdateable = collection.getKey().isUpdateable(); }
public OneToManyPersister(Collection collection, CacheConcurrencyStrategy cache, Configuration cfg, SessionFactoryImplementor factory) throws MappingException, CacheException { super( collection, cache, cfg, factory ); cascadeDeleteEnabled = collection.getKey().isCascadeDeleteEnabled() && factory.getDialect().supportsCascadeDelete(); keyIsNullable = collection.getKey().isNullable(); keyIsUpdateable = collection.getKey().isUpdateable(); }
public String getIdentitySelectString() { //TODO: cache this in an instvar return getFactory().getDialect().getIdentitySelectString( getTableName(0), getKeyColumns(0)[0], getIdentifierType().sqlTypes( getFactory() )[0] ); }
public String getSelectByUniqueKeyString(String propertyName) { return new SimpleSelect( getFactory().getDialect() ) .setTableName( getTableName(0) ) .addColumns( getKeyColumns(0) ) .addCondition( getPropertyColumnNames(propertyName), "=?" ) .toStatementString(); }
protected String generateLockString() { SessionFactoryImplementor factory = lockable.getFactory(); Update update = new Update( factory.getDialect() ); update.setTableName( lockable.getRootTableName() ); update.setPrimaryKeyColumnNames( lockable.getRootTableIdentifierColumnNames() ); update.setVersionColumnName( lockable.getVersionColumnName() ); update.addColumn( lockable.getVersionColumnName() ); if ( factory.getSettings().isCommentsEnabled() ) { update.setComment( lockMode + " lock " + lockable.getEntityName() ); } return update.toStatementString(); }