private void setStatementFetchSize(PreparedStatement statement) throws SQLException { Integer statementFetchSize = factory.getSettings().getJdbcFetchSize(); if ( statementFetchSize!=null ) { statement.setFetchSize( statementFetchSize.intValue() ); } }
private void log(String sql) { SQL_LOG.debug(sql); if ( factory.getSettings().isShowSqlEnabled() ) System.out.println("Hibernate: " + sql); }
public static void setSessionFactory(final SessionFactory sessionFactory) { CacheEntry.sessionFactory = sessionFactory; CacheEntry.entityMode = ((SessionFactoryImplementor) sessionFactory).getSettings().getDefaultEntityMode(); }
/** * Mainly for subclass usage. This impl always returns after_transaction. * * @return The connection release mode for any built sessions. */ protected ConnectionReleaseMode getConnectionReleaseMode() { return factory.getSettings().getConnectionReleaseMode(); }
private String getSchemaPrefix() throws SQLException { String schemaPrefix = ""; final String defaultSchema = ((SessionFactoryImplementor) session.getSessionFactory()).getSettings() .getDefaultSchemaName(); if (defaultSchema != null && !defaultSchema.trim().isEmpty()) { schemaPrefix = defaultSchema + "."; } return schemaPrefix; }
public void sortCollectionActions() { if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) { //sort the updates by fk java.util.Collections.sort( collectionCreations ); java.util.Collections.sort( collectionUpdates ); java.util.Collections.sort( collectionRemovals ); } }
/** * Used during deserialization. * * @param ois The stream from which we are being read. * @throws IOException Indicates an I/O error reading the stream * @throws ClassNotFoundException Indicates resource class resolution. */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { factory = ( SessionFactoryImplementor ) ois.readObject(); ois.defaultReadObject(); this.batcher = factory.getSettings().getBatcherFactory().createBatcher( this ); }
public void sortUpdateActions() { if ( session.getFactory().getSettings().isOrderUpdatesEnabled() ) { //sort the updates by pk java.util.Collections.sort( updates ); } }
private void log(String sql) { if ( SQL_LOG.isDebugEnabled() ) { SQL_LOG.debug( format(sql) ); } if ( factory.getSettings().isShowSqlEnabled() ) { System.out.println( "Hibernate: " + format(sql) ); } }
public Transaction beginTransaction() throws HibernateException { Transaction tx = owner.getFactory().getSettings().getTransactionFactory() .beginTransaction( this, owner ); isHibernateTransactionActive = true; return tx; }
public Transaction getTransaction() throws HibernateException { if (hibernateTransaction==null) { hibernateTransaction = owner.getFactory().getSettings() .getTransactionFactory() .createTransaction( this, owner ); } return hibernateTransaction; }
private String format(String sql) { if ( factory.getSettings().isFormatSqlEnabled() ) { return new Formatter(sql).format(); } else { return sql; } }
public boolean isTransactionInProgress() { return owner.getFactory().getSettings().getTransactionFactory() .isTransactionInProgress( this, owner, hibernateTransaction ); }
/** * Modify the SQL, adding lock hints and comments, if necessary */ protected String preprocessSQL(String sql, QueryParameters parameters, Dialect dialect) throws HibernateException { sql = applyLocks( sql, parameters.getLockModes(), dialect ); return getFactory().getSettings().isCommentsEnabled() ? prependComment( sql, parameters ) : sql; }
public boolean isBatchable() { return optimisticLockMode()==Versioning.OPTIMISTIC_LOCK_NONE || ( !isVersioned() && optimisticLockMode()==Versioning.OPTIMISTIC_LOCK_VERSION ) || getFactory().getSettings().isJdbcBatchVersionedData(); }
public void execute(Executable executable) { final boolean lockQueryCache = session.getFactory().getSettings().isQueryCacheEnabled(); if ( executable.hasAfterTransactionCompletion() || lockQueryCache ) { executions.add( executable ); } if (lockQueryCache) { session.getFactory() .getUpdateTimestampsCache() .preinvalidate( executable.getPropertySpaces() ); } executable.execute(); }
private static boolean useMinimalPuts(SessionImplementor session, EntityEntry entityEntry) { return ( session.getFactory().getSettings().isMinimalPutsEnabled() && session.getCacheMode()!=CacheMode.REFRESH ) || ( entityEntry.getPersister().hasLazyProperties() && entityEntry.isLoadedWithLazyPropertiesUnfetched() && entityEntry.getPersister().isLazyPropertiesCacheable() ); }
/** * Generate the SQL DELETE that deletes all rows */ protected String generateDeleteString() { Delete delete = new Delete() .setTableName( qualifiedTableName ) .setPrimaryKeyColumnNames( keyColumnNames ); if ( hasWhere ) delete.setWhere( sqlWhereString ); if ( getFactory().getSettings().isCommentsEnabled() ) { delete.setComment( "delete collection " + getRole() ); } return delete.toStatementString(); }
/** * Generate the SQL DELETE that deletes all rows */ protected String generateDeleteString() { Delete delete = new Delete() .setTableName( qualifiedTableName ) .setPrimaryKeyColumnNames( keyColumnNames ); if ( hasWhere ) delete.setWhere( sqlWhereString ); if ( getFactory().getSettings().isCommentsEnabled() ) { delete.setComment( "delete collection " + getRole() ); } return delete.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(); }