private static void logQuery(String hql, String sql) { if ( LOG.isDebugEnabled() ) { LOG.debugf( "HQL: %s", hql ); LOG.debugf( "SQL: %s", sql ); } }
if ( LOG.isEnabled( Level.ERROR ) ) { if ( LOG.isDebugEnabled() ) { message = StringHelper.isNotEmpty( message ) ? message : DEFAULT_EXCEPTION_MSG; LOG.debug( message, sqlException ); final boolean warnEnabled = LOG.isEnabled( Level.WARN ); String warnMessage = "SQL Error: " + sqlException.getErrorCode() + ", SQLState: " + sqlException.getSQLState(); if ( !previousWarnMessages.contains( warnMessage ) ) { LOG.warn( warnMessage ); previousWarnMessages.add( warnMessage ); LOG.error( sqlException.getMessage() ); previousErrorMessages.add( sqlException.getMessage() );
@Override public void traceOut(String ruleName) { if ( !LOG.isTraceEnabled() ) { return; } if ( inputState.guessing > 0 ) { return; } String prefix = "<-" + StringHelper.repeat( '-', ( --traceDepth * 2 ) ) + " "; LOG.trace( prefix + ruleName ); }
private void logDuplicateRegistration(String path, Type existingType, Type type) { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Skipping duplicate registration of path [{0}], existing type = [{1}], incoming type = [{2}]", path, existingType, type ); } }
@Override public void addImport(String importName, String entityName) { if ( importName == null || entityName == null ) { throw new IllegalArgumentException( "Import name or entity name is null" ); } log.tracev( "Import: {0} -> {1}", importName, entityName ); String old = imports.put( importName, entityName ); if ( old != null ) { log.debug( "import name [" + importName + "] overrode previous [{" + old + "}]" ); } }
private static void writeSerFile(Serializable binding, File xmlFile, File serFile) { try { log.debugf( "Writing cache file for: %s to: %s", xmlFile.getAbsolutePath(), serFile.getAbsolutePath() ); SerializationHelper.serialize( binding, new FileOutputStream( serFile ) ); boolean success = serFile.setLastModified( System.currentTimeMillis() ); if ( !success ) { log.warn( "Could not update cacheable hbm.xml bin file timestamp" ); } } catch ( Exception e ) { log.unableToWriteCachedFile( serFile.getAbsolutePath(), e.getMessage() ); } }
void showHqlAst(AST hqlAst) { if ( LOG.isDebugEnabled() ) { LOG.debug( TokenPrinters.HQL_TOKEN_PRINTER.showAsString( hqlAst, "--- HQL AST ---" ) ); } }
public void bind(PreparedStatement preparedStatement, int position) throws SQLException { // TODO : bind it as 'exact type'? Not sure if that gains us anything... LOG.tracef( "binding parameter [%s] - [%s]", position, value ); preparedStatement.setLong( position, value ); }
private InputSource buildInputSource(String publicId, String systemId, InputStream dtdStream, boolean resolved) { if ( dtdStream == null ) { LOG.tracev( "Unable to locate [{0}] on classpath", systemId ); return null; } LOG.tracev( "Located [{0}] in classpath", systemId ); InputSource source = new InputSource( dtdStream ); source.setPublicId( publicId ); source.setSystemId( systemId ); this.resolved = resolved; return source; }
@SuppressWarnings({"unchecked"}) public static void close(ResultSet resultSet) { log.tracef( "Closing result set [%s]", resultSet ); try { resultSet.close(); } catch (SQLException e) { log.debugf( "Unable to release JDBC result set [%s]", e.getMessage() ); } catch (Exception e) { // try to handle general errors more elegantly log.debugf( "Unable to release JDBC result set [%s]", e.getMessage() ); } }
LOG.warn("Cannot access transaction manager", ex); canAccessTransactionManager = false; LOG.autoFlushWillNotWork(); LOG.unableToConstructCurrentSessionContext(impl, t); return null;
private void beforeStatement(String statementName, int statementType) { inFunctionCall = false; level++; if ( level == 1 ) { this.statementTypeName = statementName; this.statementType = statementType; } currentStatementType = statementType; LOG.debugf("%s << begin [level=%s, statement=%s]", statementName, level, this.statementTypeName); }
LOG.unableToReadOrInitHiValue( sqle ); throw sqle; LOG.error( LOG.unableToUpdateHiValue( tableName ), sqle ); throw sqle;
String logMessage = LOG.bytecodeEnhancementFailedBecauseOfDefaultConstructor( entityName ); LOG.error( logMessage, e ); throw new HibernateException( logMessage, e ); String logMessage = LOG.bytecodeEnhancementFailed( entityName ); LOG.error( logMessage, t ); throw new HibernateException( logMessage, t );
LOG.autoFlushWillNotWork(); LOG.unableToConstructCurrentSessionContext( impl, t ); return null;
/** * Create the subselect fetch query fragment for the provided {@link QueryParameters} * with SELECT and ORDER BY clauses removed. * * @param queryParameters -the query parameters. * @return the subselect fetch query fragment. */ public static String createSubselectFetchQueryFragment(QueryParameters queryParameters) { //TODO: ugly here: final String queryString = queryParameters.getFilteredSQL(); final int fromIndex = getFromIndex( queryString ); final int orderByIndex = queryString.lastIndexOf( "order by" ); final String subselectQueryFragment = orderByIndex > 0 ? queryString.substring( fromIndex, orderByIndex ) : queryString.substring( fromIndex ); if ( LOG.isTraceEnabled() ) { LOG.tracef( "SubselectFetch query fragment: %s", subselectQueryFragment ); } return subselectQueryFragment; }
/** * Open an InputStream to the URL represented by the incoming path. First makes a call * to {@link #locateConfig(java.lang.String)} in order to find an appropriate URL. * {@link java.net.URL#openStream()} is then called to obtain the stream. * * @param path The path representing the config location. * * @return An input stream to the requested config resource. * * @throws HibernateException Unable to open stream to that resource. */ public static InputStream getConfigStream(final String path) throws HibernateException { final URL url = ConfigHelper.locateConfig( path ); if ( url == null ) { String msg = LOG.unableToLocateConfigFile( path ); LOG.error( msg ); throw new HibernateException( msg ); } try { return url.openStream(); } catch (IOException e) { throw new HibernateException( "Unable to open config file: " + path, e ); } }
@Override public void reportError(String message) { LOG.error( message ); errorList.add( message ); }