Java PersistenceContext.isDefaultReadOnly方法代码示例

本文整理汇总了Java中org.hibernate.engine.spi.PersistenceContext.isDefaultReadOnly方法的典型用法代码示例。如果您正苦于以下问题:Java PersistenceContext.isDefaultReadOnly方法的具体用法?Java PersistenceContext.isDefaultReadOnly怎么用?Java PersistenceContext.isDefaultReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.engine.spi.PersistenceContext的用法示例。


Java PersistenceContext.isDefaultReadOnly方法代码示例

在下文中一共展示了PersistenceContext.isDefaultReadOnly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doQueryAndInitializeNonLazyCollections

import org.hibernate.engine.spi.PersistenceContext; //导入方法依赖的package包/类
public List doQueryAndInitializeNonLazyCollections(
		final SessionImplementor session,
		final QueryParameters queryParameters,
		final boolean returnProxies,
		final ResultTransformer forcedResultTransformer)
		throws HibernateException, SQLException {
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
	if ( queryParameters.isReadOnlyInitialized() ) {
		// The read-only/modifiable mode for the query was explicitly set.
		// Temporarily set the default read-only/modifiable setting to the query's setting.
		persistenceContext.setDefaultReadOnly( queryParameters.isReadOnly() );
	}
	else {
		// The read-only/modifiable setting for the query was not initialized.
		// Use the default read-only/modifiable from the persistence context instead.
		queryParameters.setReadOnly( persistenceContext.isDefaultReadOnly() );
	}
	persistenceContext.beforeLoad();
	List result;
	try {
		try {
			result = doQuery( session, queryParameters, returnProxies, forcedResultTransformer );
		}
		finally {
			persistenceContext.afterLoad();
		}
		persistenceContext.initializeNonLazyCollections();
	}
	finally {
		// Restore the original default
		persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
	}
	return result;
} 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:Loader.java

示例2: doEntityBatchFetch

import org.hibernate.engine.spi.PersistenceContext; //导入方法依赖的package包/类
public List doEntityBatchFetch(
		SessionImplementor session,
		QueryParameters queryParameters,
		Serializable[] ids) {
	final String sql = StringHelper.expandBatchIdPlaceholder(
			sqlTemplate,
			ids,
			alias,
			persister.getKeyColumnNames(),
			getFactory().getDialect()
	);

	try {
		final PersistenceContext persistenceContext = session.getPersistenceContext();
		boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
		if ( queryParameters.isReadOnlyInitialized() ) {
			// The read-only/modifiable mode for the query was explicitly set.
			// Temporarily set the default read-only/modifiable setting to the query's setting.
			persistenceContext.setDefaultReadOnly( queryParameters.isReadOnly() );
		}
		else {
			// The read-only/modifiable setting for the query was not initialized.
			// Use the default read-only/modifiable from the persistence context instead.
			queryParameters.setReadOnly( persistenceContext.isDefaultReadOnly() );
		}
		persistenceContext.beforeLoad();
		List results;
		try {
			try {
				results = doTheLoad( sql, queryParameters, session );
			}
			finally {
				persistenceContext.afterLoad();
			}
			persistenceContext.initializeNonLazyCollections();
			log.debug( "Done batch load" );
			return results;
		}
		finally {
			// Restore the original default
			persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
		}
	}
	catch ( SQLException sqle ) {
		throw session.getFactory().getSQLExceptionHelper().convert(
				sqle,
				"could not load an entity batch: " + MessageHelper.infoString(
						getEntityPersisters()[0],
						ids,
						session.getFactory()
				),
				sql
		);
	}
} 
开发者ID:lamsfoundation,项目名称:lams,代码行数:56,代码来源:DynamicBatchingEntityLoaderBuilder.java

示例3: getResultFromQueryCache

import org.hibernate.engine.spi.PersistenceContext; //导入方法依赖的package包/类
private List getResultFromQueryCache(
		final SessionImplementor session,
		final QueryParameters queryParameters,
		final Set<Serializable> querySpaces,
		final Type[] resultTypes,
		final QueryCache queryCache,
		final QueryKey key) {
	List result = null;

	if ( session.getCacheMode().isGetEnabled() ) {
		boolean isImmutableNaturalKeyLookup =
				queryParameters.isNaturalKeyLookup() &&
						resultTypes.length == 1 &&
						resultTypes[0].isEntityType() &&
						getEntityPersister( EntityType.class.cast( resultTypes[0] ) )
								.getEntityMetamodel()
								.hasImmutableNaturalId();

		final PersistenceContext persistenceContext = session.getPersistenceContext();
		boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
		if ( queryParameters.isReadOnlyInitialized() ) {
			// The read-only/modifiable mode for the query was explicitly set.
			// Temporarily set the default read-only/modifiable setting to the query's setting.
			persistenceContext.setDefaultReadOnly( queryParameters.isReadOnly() );
		}
		else {
			// The read-only/modifiable setting for the query was not initialized.
			// Use the default read-only/modifiable from the persistence context instead.
			queryParameters.setReadOnly( persistenceContext.isDefaultReadOnly() );
		}
		try {
			result = queryCache.get(
					key,
					key.getResultTransformer().getCachedResultTypes( resultTypes ),
					isImmutableNaturalKeyLookup,
					querySpaces,
					session
			);
		}
		finally {
			persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
		}

		if ( factory.getStatistics().isStatisticsEnabled() ) {
			if ( result == null ) {
				factory.getStatisticsImplementor()
						.queryCacheMiss( getQueryIdentifier(), queryCache.getRegion().getName() );
			}
			else {
				factory.getStatisticsImplementor()
						.queryCacheHit( getQueryIdentifier(), queryCache.getRegion().getName() );
			}
		}
	}

	return result;
} 
开发者ID:lamsfoundation,项目名称:lams,代码行数:58,代码来源:Loader.java

示例4: doBatchedCollectionLoad

import org.hibernate.engine.spi.PersistenceContext; //导入方法依赖的package包/类
public final void doBatchedCollectionLoad(
		final SessionImplementor session,
		final Serializable[] ids,
		final Type type) throws HibernateException {

	if ( LOG.isDebugEnabled() )
		LOG.debugf( "Batch loading collection: %s",
					MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ) );

	final Type[] idTypes = new Type[ids.length];
	Arrays.fill( idTypes, type );
	final QueryParameters queryParameters = new QueryParameters( idTypes, ids, ids );

	final String sql = StringHelper.expandBatchIdPlaceholder(
			sqlTemplate,
			ids,
			alias,
			collectionPersister().getKeyColumnNames(),
			getFactory().getDialect()
	);

	try {
		final PersistenceContext persistenceContext = session.getPersistenceContext();
		boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
		if ( queryParameters.isReadOnlyInitialized() ) {
			// The read-only/modifiable mode for the query was explicitly set.
			// Temporarily set the default read-only/modifiable setting to the query's setting.
			persistenceContext.setDefaultReadOnly( queryParameters.isReadOnly() );
		}
		else {
			// The read-only/modifiable setting for the query was not initialized.
			// Use the default read-only/modifiable from the persistence context instead.
			queryParameters.setReadOnly( persistenceContext.isDefaultReadOnly() );
		}
		persistenceContext.beforeLoad();
		try {
			try {
				doTheLoad( sql, queryParameters, session );
			}
			finally {
				persistenceContext.afterLoad();
			}
			persistenceContext.initializeNonLazyCollections();
		}
		finally {
			// Restore the original default
			persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
		}
	}
	catch ( SQLException e ) {
		throw getFactory().getSQLExceptionHelper().convert(
				e,
				"could not initialize a collection batch: " +
						MessageHelper.collectionInfoString( collectionPersister(), ids, getFactory() ),
				sql
		);
	}

	LOG.debug( "Done batch load" );

} 
开发者ID:lamsfoundation,项目名称:lams,代码行数:62,代码来源:DynamicBatchingCollectionInitializerBuilder.java

示例5: executeLoad

import org.hibernate.engine.spi.PersistenceContext; //导入方法依赖的package包/类
protected List executeLoad(
		SessionImplementor session,
		QueryParameters queryParameters,
		LoadQueryDetails loadQueryDetails,
		boolean returnProxies,
		ResultTransformer forcedResultTransformer,
		List<AfterLoadAction> afterLoadActions) throws SQLException {
	final PersistenceContext persistenceContext = session.getPersistenceContext();
	final boolean defaultReadOnlyOrig = persistenceContext.isDefaultReadOnly();
	if ( queryParameters.isReadOnlyInitialized() ) {
		// The read-only/modifiable mode for the query was explicitly set.
		// Temporarily set the default read-only/modifiable setting to the query's setting.
		persistenceContext.setDefaultReadOnly( queryParameters.isReadOnly() );
	}
	else {
		// The read-only/modifiable setting for the query was not initialized.
		// Use the default read-only/modifiable from the persistence context instead.
		queryParameters.setReadOnly( persistenceContext.isDefaultReadOnly() );
	}
	persistenceContext.beforeLoad();
	try {
		List results = null;
		final String sql = loadQueryDetails.getSqlStatement();
		SqlStatementWrapper wrapper = null;
		try {
			wrapper = executeQueryStatement( sql, queryParameters, false, afterLoadActions, session );
			results = loadQueryDetails.getResultSetProcessor().extractResults(
					wrapper.getResultSet(),
					session,
					queryParameters,
					new NamedParameterContext() {
						@Override
						public int[] getNamedParameterLocations(String name) {
							return AbstractLoadPlanBasedLoader.this.getNamedParameterLocs( name );
						}
					},
					returnProxies,
					queryParameters.isReadOnly(),
					forcedResultTransformer,
					afterLoadActions
			);
		}
		finally {
			if ( wrapper != null ) {
				session.getTransactionCoordinator().getJdbcCoordinator().release(
						wrapper.getResultSet(),
						wrapper.getStatement()
				);
				session.getTransactionCoordinator().getJdbcCoordinator().release( wrapper.getStatement() );
			}
			persistenceContext.afterLoad();
		}
		persistenceContext.initializeNonLazyCollections();
		return results;
	}
	finally {
		// Restore the original default
		persistenceContext.setDefaultReadOnly( defaultReadOnlyOrig );
	}
} 
开发者ID:lamsfoundation,项目名称:lams,代码行数:61,代码来源:AbstractLoadPlanBasedLoader.java

本文标签属性:

示例:示例英文

代码:代码编程

java:java面试题

PersistenceContext:persistencecontext注解

isDefaultReadOnly:isDefaultReadOnly

上一篇:Golang RequestBundle.VerifyEmail方法代码示例
下一篇:隐私是什么意思?(隐私的意思隐私的意思是什么)

为您推荐