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 ); }
@Override @SuppressWarnings("unchecked") public void register(Statement statement, boolean cancelable) { log.tracef( "Registering statement [%s]", statement ); Set<ResultSet> previousValue = xref.putIfAbsent( statement, Collections.EMPTY_SET ); if ( previousValue != null ) { throw new HibernateException( "JDBC Statement already registered" ); } if ( cancelable ) { lastQuery = statement; } }
@Override public void sessionFactoryCreated(SessionFactory factory) { // Instead of allowing scope#setSessionFactory to influence this, we use the SessionFactoryObserver callback // to handle this, allowing any SessionFactory constructor code to be able to continue to have access to the // MetadataBuildingContext through TypeConfiguration until this callback is fired. log.tracef( "Handling #sessionFactoryCreated from [%s] for TypeConfiguration", factory ); scope.setMetadataBuildingContext( null ); }
/** * Create an initial optimistic locking value according the {@link VersionType} * contract for the version property. * * @param versionType The version type. * @param session The originating session * @return The initial optimistic locking value */ private static Object seed(VersionType versionType, SharedSessionContractImplementor session) { final Object seed = versionType.seed( session ); LOG.tracef( "Seeding: %s", seed ); return seed; }
@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() ); } }
@Override public Object getObjectInstance(Object reference, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { LOG.debugf( "JNDI lookup: %s", name ); final String uuid = (String) ( (Reference) reference ).get( 0 ).getContent(); LOG.tracef( "Resolved to UUID = %s", uuid ); return INSTANCE.getSessionFactory( uuid ); } }
protected void doAfterCompletion(boolean successful, boolean delayed) { log.tracef( "Synchronization coordinator: doAfterCompletion(successful=%s, delayed=%s)", successful, delayed ); try { target.afterCompletion( successful, delayed ); } finally { reset(); } }
private void registerDelayedPropertyReferenceHandler( DelayedPropertyReferenceHandlerImpl handler, MetadataBuildingContext buildingContext) { log.tracef( "Property [%s.%s] referenced by property-ref [%s] was not yet available - creating delayed handler", handler.referencedEntityName, handler.referencedPropertyName, handler.sourceElementSynopsis ); buildingContext.getMetadataCollector().addDelayedPropertyReferenceHandler( handler ); }
@Override public void sessionFactoryClosed(SessionFactory factory) { log.tracef( "Handling #sessionFactoryClosed from [%s] for TypeConfiguration", factory ); TypeConfigurationRegistry.INSTANCE.deregisterTypeConfiguration( this ); scope.unsetSessionFactory( factory ); // todo (6.0) : finish this // release Database, descriptor Maps, etc... things that are only // valid while the TypeConfiguration is scoped to SessionFactory }
@Override public void afterCompletion(int status) { log.tracef( "Synchronization coordinator: afterCompletion(status=%s)", status ); doAfterCompletion( JtaStatusHelper.isCommitted( status ), false ); }
/** * 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; }
@Override public void queryCacheMiss(String hql, String regionName) { LOG.tracef( "Statistics#queryCacheMiss( `%s`, `%s` )", hql, regionName ); queryCacheMissCount.increment(); getQueryRegionStats( regionName ).incrementMissCount(); if ( hql != null ) { getQueryStatistics( hql ).incrementCacheMissCount(); } }
@Override public void queryCachePut(String hql, String regionName) { LOG.tracef( "Statistics#queryCachePut( `%s`, `%s` )", hql, regionName ); queryCachePutCount.increment(); getQueryRegionStats( regionName ).incrementPutCount(); if ( hql != null ) { getQueryStatistics( hql ).incrementCachePutCount(); } }
@Override public void queryCacheHit(String hql, String regionName) { LOG.tracef( "Statistics#queryCacheHit( `%s`, `%s` )", hql, regionName ); queryCacheHitCount.increment(); getQueryRegionStats( regionName ).incrementHitCount(); if ( hql != null ) { getQueryStatistics( hql ).incrementCacheHitCount(); } }
/** * JDK serialization hook for serializing * * @param oos The stream to write ourselves to * * @throws IOException Indicates an IO exception accessing the given stream */ public void serialize(ObjectOutputStream oos) throws IOException { log.tracef( "Starting serialization of [%s] EntityEntry entries", count ); oos.writeInt( count ); if ( count == 0 ) { return; } ManagedEntity managedEntity = head; while ( managedEntity != null ) { // so we know whether or not to build a ManagedEntityImpl on deserialize oos.writeBoolean( managedEntity == managedEntity.$$_hibernate_getEntityInstance() ); oos.writeObject( managedEntity.$$_hibernate_getEntityInstance() ); // we need to know which implementation of EntityEntry is being serialized oos.writeInt( managedEntity.$$_hibernate_getEntityEntry().getClass().getName().length() ); oos.writeChars( managedEntity.$$_hibernate_getEntityEntry().getClass().getName() ); managedEntity.$$_hibernate_getEntityEntry().serialize( oos ); managedEntity = managedEntity.$$_hibernate_getNextManagedEntity(); } }
@Override public void afterCompletion(int status) { log.tracef( "Synchronization coordinator: afterCompletion(status=%s)", status ); // The whole concept of "tracking" comes down to this code block.. // Essentially we need to see if we can process the callback immediately. So here we check whether the // current call is happening on the same thread as the thread under which we registered the Synchronization. // As far as we know, this can only ever happen in the rollback case where the transaction had been rolled // back on a separate "reaper" thread. Since we know the transaction status and that check is not as heavy // as accessing the current thread, we check that first if ( JtaStatusHelper.isRollback( status ) ) { // we are processing a rollback, see if it is the same thread final long currentThreadId = Thread.currentThread().getId(); final boolean isRegistrationThread = currentThreadId == registrationThreadId; if ( ! isRegistrationThread ) { // so we do have the condition of a rollback initiated from a separate thread. Set the flag here and // check for it in SessionImpl. See HHH-7910. delayedCompletionHandling = true; log.rollbackFromBackgroundThread( status ); return; } } // otherwise, do the callback immediately doAfterCompletion( JtaStatusHelper.isCommitted( status ), false ); }
private void afterCompletionCallback(boolean successful) { log.tracef( "ResourceLocalTransactionCoordinatorImpl#afterCompletionCallback(%s)", successful ); final int statusToSend = successful ? Status.STATUS_COMMITTED : Status.STATUS_UNKNOWN; synchronizationRegistry.notifySynchronizationsAfterTransactionCompletion( statusToSend ); transactionCoordinatorOwner.afterTransactionCompletion( successful, false ); for ( TransactionObserver observer : observers() ) { observer.afterCompletion( successful, false ); } }
/** * Generate the next increment in the optimistic locking value according * the {@link VersionType} contract for the version property. * * @param version The current version * @param versionType The version type * @param session The originating session * @return The incremented optimistic locking value. */ @SuppressWarnings("unchecked") public static Object increment(Object version, VersionType versionType, SharedSessionContractImplementor session) { final Object next = versionType.next( version, session ); if ( LOG.isTraceEnabled() ) { LOG.tracef( "Incrementing: %s to %s", versionType.toLoggableString( version, session.getFactory() ), versionType.toLoggableString( next, session.getFactory() ) ); } return next; }
@SuppressWarnings({"unchecked"}) private void entityIsDeleted(PersistEvent event, Map createCache) { final EventSource source = event.getSession(); final Object entity = source.getPersistenceContext().unproxy( event.getObject() ); final EntityPersister persister = source.getEntityPersister( event.getEntityName(), entity ); LOG.tracef( "un-scheduling entity deletion [%s]", MessageHelper.infoString( persister, persister.getIdentifier( entity, source ), source.getFactory() ) ); if ( createCache.put( entity, entity ) == null ) { justCascade( createCache, source, entity, persister ); } } }
/** * Attempt to locate the loading collection given the owner's key. The lookup here * occurs against all result-set contexts... * * @param persister The collection persister * @param ownerKey The owner key * @return The loading collection, or null if not found. */ public PersistentCollection locateLoadingCollection(CollectionPersister persister, Serializable ownerKey) { final LoadingCollectionEntry lce = locateLoadingCollectionEntry( new CollectionKey( persister, ownerKey ) ); if ( lce != null ) { if ( LOG.isTraceEnabled() ) { LOG.tracef( "Returning loading collection: %s", MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) ); } return lce.getCollection(); } return null; }