當前位置: 首頁>>代碼示例>>Java>>正文


Java SessionImplementor類代碼示例

本文整理匯總了Java中org.hibernate.engine.spi.SessionImplementor的典型用法代碼示例。如果您正苦於以下問題:Java SessionImplementor類的具體用法?Java SessionImplementor怎麽用?Java SessionImplementor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SessionImplementor類屬於org.hibernate.engine.spi包,在下文中一共展示了SessionImplementor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getUpdateId

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
/**
 * Determine the id to use for updating.
 *
 * @param entity The entity.
 * @param persister The entity persister
 * @param requestedId The requested identifier
 * @param session The session
 *
 * @return The id.
 *
 * @throws TransientObjectException If the entity is considered transient.
 */
protected Serializable getUpdateId(
		Object entity,
		EntityPersister persister,
		Serializable requestedId,
		SessionImplementor session) {
	// use the id assigned to the instance
	Serializable id = persister.getIdentifier( entity, session );
	if ( id == null ) {
		// assume this is a newly instantiated transient object
		// which should be saved rather than updated
		throw new TransientObjectException(
				"The given object has a null identifier: " +
						persister.getEntityName()
		);
	}
	else {
		return id;
	}

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:33,代碼來源:DefaultSaveOrUpdateEventListener.java

示例2: getAppropriateInitializer

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
protected CollectionInitializer getAppropriateInitializer(Serializable key, SessionImplementor session) {
	if ( queryLoaderName != null ) {
		// if there is a user-specified loader, return that
		// TODO: filters!?
		return initializer;
	}
	CollectionInitializer subselectInitializer = getSubselectInitializer( key, session );
	if ( subselectInitializer != null ) {
		return subselectInitializer;
	}
	else if ( session.getEnabledFilters().isEmpty() ) {
		return initializer;
	}
	else {
		return createCollectionInitializer( session.getLoadQueryInfluencers() );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:AbstractCollectionPersister.java

示例3: EntityIdentityInsertAction

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
/**
 * Constructs an EntityIdentityInsertAction
 *
 * @param state The current (extracted) entity state
 * @param instance The entity instance
 * @param persister The entity persister
 * @param isVersionIncrementDisabled Whether version incrementing is disabled
 * @param session The session
 * @param isDelayed Are we in a situation which allows the insertion to be delayed?
 *
 * @throws HibernateException Indicates an illegal state
 */
public EntityIdentityInsertAction(
		Object[] state,
		Object instance,
		EntityPersister persister,
		boolean isVersionIncrementDisabled,
		SessionImplementor session,
		boolean isDelayed) {
	super(
			( isDelayed ? generateDelayedPostInsertIdentifier() : null ),
			state,
			instance,
			isVersionIncrementDisabled,
			persister,
			session
	);
	this.isDelayed = isDelayed;
	this.delayedEntityKey = isDelayed ? generateDelayedEntityKey() : null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:EntityIdentityInsertAction.java

示例4: handleInterception

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
protected boolean handleInterception(FlushEntityEvent event) {
	SessionImplementor session = event.getSession();
	EntityEntry entry = event.getEntityEntry();
	EntityPersister persister = entry.getPersister();
	Object entity = event.getEntity();

	//give the Interceptor a chance to modify property values
	final Object[] values = event.getPropertyValues();
	final boolean intercepted = invokeInterceptor( session, entity, entry, values, persister );

	//now we might need to recalculate the dirtyProperties array
	if ( intercepted && event.isDirtyCheckPossible() && !event.isDirtyCheckHandledByInterceptor() ) {
		int[] dirtyProperties;
		if ( event.hasDatabaseSnapshot() ) {
			dirtyProperties = persister.findModified( event.getDatabaseSnapshot(), values, entity, session );
		}
		else {
			dirtyProperties = persister.findDirty( values, entry.getLoadedState(), entity, session );
		}
		event.setDirtyProperties( dirtyProperties );
	}

	return intercepted;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:DefaultFlushEntityEventListener.java

示例5: load

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
@Override
public Object load(
		Serializable id,
		Object optionalObject,
		SessionImplementor session,
		LockOptions lockOptions) {
	final Serializable[] batch = session.getPersistenceContext()
			.getBatchFetchQueue()
			.getEntityBatch( persister(), id, maxBatchSize, persister().getEntityMode() );

	final int numberOfIds = ArrayHelper.countNonNull( batch );
	if ( numberOfIds <= 1 ) {
		return singleKeyLoader.load( id, optionalObject, session );
	}

	final Serializable[] idsToLoad = new Serializable[numberOfIds];
	System.arraycopy( batch, 0, idsToLoad, 0, numberOfIds );

	if ( log.isDebugEnabled() ) {
		log.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister(), idsToLoad, session.getFactory() ) );
	}

	QueryParameters qp = buildQueryParameters( id, idsToLoad, optionalObject, lockOptions );
	List results = dynamicLoader.doEntityBatchFetch( session, qp, idsToLoad );
	return getObjectFromList( results, id, session );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:DynamicBatchingEntityLoaderBuilder.java

示例6: isModified

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
@Override
public boolean isModified(final Object old, final Object current, final boolean[] checkable, final SessionImplementor session) throws HibernateException {
	if ( current == null ) {
		return old != null;
	}
	if ( old == null ) {
		return true;
	}
	Object[] oldValues = ( Object[] ) old;
	int loc = 0;
	for ( int i = 0; i < propertySpan; i++ ) {
		int len = propertyTypes[i].getColumnSpan( session.getFactory() );
		boolean[] subcheckable = new boolean[len];
		System.arraycopy( checkable, loc, subcheckable, 0, len );
		if ( propertyTypes[i].isModified( oldValues[i], getPropertyValue( current, i ), subcheckable, session ) ) {
			return true;
		}
		loc += len;
	}
	return false;

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:23,代碼來源:ComponentType.java

示例7: buildResultRow

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
public Object[] buildResultRow(Object[] data, ResultSet resultSet, SessionImplementor session)
		throws SQLException, HibernateException {
	Object[] resultRow;
	if ( !hasScalars ) {
		resultRow = data;
	}
	else {
		// build an array with indices equal to the total number
		// of actual returns in the result Hibernate will return
		// for this query (scalars + non-scalars)
		resultRow = new Object[ columnProcessors.length ];
		for ( int i = 0; i < columnProcessors.length; i++ ) {
			resultRow[i] = columnProcessors[i].extract( data, resultSet, session );
		}
	}

	return resultRow;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:ResultRowProcessor.java

示例8: applyPostLoadLocks

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
@Override
	protected void applyPostLoadLocks(Object[] row, LockMode[] lockModesArray, SessionImplementor session) {
		// todo : scalars???
//		if ( row.length != lockModesArray.length ) {
//			return;
//		}
//
//		for ( int i = 0; i < lockModesArray.length; i++ ) {
//			if ( LockMode.OPTIMISTIC_FORCE_INCREMENT.equals( lockModesArray[i] ) ) {
//				final EntityEntry pcEntry =
//			}
//			else if ( LockMode.PESSIMISTIC_FORCE_INCREMENT.equals( lockModesArray[i] ) ) {
//
//			}
//		}
	}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:QueryLoader.java

示例9: shouldUseFollowOnLocking

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
protected boolean shouldUseFollowOnLocking(
		QueryParameters parameters,
		Dialect dialect,
		List<AfterLoadAction> afterLoadActions) {
	if ( dialect.useFollowOnLocking() ) {
		// currently only one lock mode is allowed in follow-on locking
		final LockMode lockMode = determineFollowOnLockMode( parameters.getLockOptions() );
		final LockOptions lockOptions = new LockOptions( lockMode );
		if ( lockOptions.getLockMode() != LockMode.UPGRADE_SKIPLOCKED ) {
			LOG.usingFollowOnLocking();
			lockOptions.setTimeOut( parameters.getLockOptions().getTimeOut() );
			lockOptions.setScope( parameters.getLockOptions().getScope() );
			afterLoadActions.add(
					new AfterLoadAction() {
						@Override
						public void afterLoad(SessionImplementor session, Object entity, Loadable persister) {
							( (Session) session ).buildLockRequest( lockOptions ).lock( persister.getEntityName(), entity );
						}
					}
			);
			parameters.setLockOptions( new LockOptions() );
			return true;
		}
	}
	return false;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:Loader.java

示例10: specificationToWork

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
private QueryPlanWork specificationToWork(Specification<T> spec, Pageable pageable) {
    // Unwrap to Hibernate
    final QueryImpl query = getQuery(spec, pageable).unwrap(QueryImpl.class);
    final String hql = query.getQueryString();

    // Create translator
    final QueryTranslator queryTranslator =
            new ASTQueryTranslatorFactory().createQueryTranslator("", hql, Collections.emptyMap(), em.unwrap(SessionImplementor.class).getFactory(), null);
    queryTranslator.compile(Collections.emptyMap(), false);

    // Get translated query and parameters
    final String sql = queryTranslator.getSQLString();
    final Object[] parameters = translateParameters(query, queryTranslator);

    // Done
    return new QueryPlanWork(sql, parameters);
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:18,代碼來源:CustomSimpleQuerycostJpaRepository.java

示例11: receiveResponse

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
protected Document receiveResponse() throws IOException, DocumentException {
    try {
        SessionImplementor session = (SessionImplementor)new _RootDAO().getSession();
        Connection connection = session.getJdbcConnectionAccess().obtainConnection();
        String response = null;
        try {
            CallableStatement call = connection.prepareCall(iResponseSql);
            call.registerOutParameter(1, java.sql.Types.CLOB);
            call.execute();
            response = call.getString(1);
            call.close();
        } finally {
        	session.getJdbcConnectionAccess().releaseConnection(connection);
        }
        if (response==null || response.length()==0) return null;
        StringReader reader = new StringReader(response);
        Document document = (new SAXReader()).read(reader);
        reader.close();
        return document;
    } catch (Exception e) {
        sLog.error("Unable to receive response: "+e.getMessage(),e);
        return null;
    } finally {
        _RootDAO.closeCurrentThreadSessions();
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:27,代碼來源:BlobRoomAvailabilityService.java

示例12: getIdOfOwnerOrNull

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
/**
 * Get the id value from the owning entity key, usually the same as the key, but might be some
 * other property, in the case of property-ref
 *
 * @param key The collection owner key
 * @param session The session from which the request is originating.
 * @return The collection owner's id, if it can be obtained from the key;
 * otherwise, null is returned
 */
public Serializable getIdOfOwnerOrNull(Serializable key, SessionImplementor session) {
	Serializable ownerId = null;
	if ( foreignKeyPropertyName == null ) {
		ownerId = key;
	}
	else {
		Type keyType = getPersister( session ).getKeyType();
		EntityPersister ownerPersister = getPersister( session ).getOwnerEntityPersister();
		// TODO: Fix this so it will work for non-POJO entity mode
		Class ownerMappedClass = ownerPersister.getMappedClass();
		if ( ownerMappedClass.isAssignableFrom( keyType.getReturnedClass() ) &&
				keyType.getReturnedClass().isInstance( key ) ) {
			// the key is the owning entity itself, so get the ID from the key
			ownerId = ownerPersister.getIdentifier( key, session );
		}
		else {
			// TODO: check if key contains the owner ID
		}
	}
	return ownerId;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:CollectionType.java

示例13: putResultInQueryCache

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
protected void putResultInQueryCache(
		final SessionImplementor session,
		final QueryParameters queryParameters,
		final Type[] resultTypes,
		final QueryCache queryCache,
		final QueryKey key,
		final List result) {
	if ( session.getCacheMode().isPutEnabled() ) {
		boolean put = queryCache.put(
				key,
				key.getResultTransformer().getCachedResultTypes( resultTypes ),
				result,
				queryParameters.isNaturalKeyLookup(),
				session
		);
		if ( put && factory.getStatistics().isStatisticsEnabled() ) {
			factory.getStatisticsImplementor()
					.queryCachePut( getQueryIdentifier(), queryCache.getRegion().getName() );
		}
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:Loader.java

示例14: addUninitializedEntity

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
/**
 * Add an uninitialized instance of an entity class, as a placeholder to ensure object
 * identity. Must be called before <tt>postHydrate()</tt>.
 *
 * Create a "temporary" entry for a newly instantiated entity. The entity is uninitialized,
 * but we need the mapping from id to instance in order to guarantee uniqueness.
 *
 * @param key The entity key
 * @param object The entity instance
 * @param persister The entity persister
 * @param lockMode The lock mode
 * @param lazyPropertiesAreUnFetched Are lazy properties still un-fetched?
 * @param session The Session
 */
public static void addUninitializedEntity(
		final EntityKey key,
		final Object object,
		final EntityPersister persister,
		final LockMode lockMode,
		final boolean lazyPropertiesAreUnFetched,
		final SessionImplementor session) {
	session.getPersistenceContext().addEntity(
			object,
			Status.LOADING,
			null,
			key,
			null,
			lockMode,
			true,
			persister,
			false,
			lazyPropertiesAreUnFetched
	);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:35,代碼來源:TwoPhaseLoad.java

示例15: generate

import org.hibernate.engine.spi.SessionImplementor; //導入依賴的package包/類
public synchronized Serializable generate(final SessionImplementor session, Object obj) {
	// maxLo < 1 indicates a hilo generator with no hilo :?
	if ( maxLo < 1 ) {
		//keep the behavior consistent even for boundary usages
		IntegralDataTypeHolder value = null;
		while ( value == null || value.lt( 0 ) ) {
			value = super.generateHolder( session );
		}
		return value.makeValue();
	}

	return hiloOptimizer.generate(
			new AccessCallback() {
				public IntegralDataTypeHolder getNextValue() {
					return generateHolder( session );
				}

				@Override
				public String getTenantIdentifier() {
					return session.getTenantIdentifier();
				}
			}
	);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:SequenceHiLoGenerator.java


注:本文中的org.hibernate.engine.spi.SessionImplementor類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。