FileDocCategorySizeDatePackage
AbstractSessionImpl.javaAPI DocHibernate 3.2.54780Thu Jun 15 00:21:06 BST 2006org.hibernate.impl

AbstractSessionImpl

public abstract class AbstractSessionImpl extends Object implements org.hibernate.engine.SessionImplementor
Functionality common to stateless and stateful sessions
author
Gavin King

Fields Summary
protected transient SessionFactoryImpl
factory
private boolean
closed
Constructors Summary
protected AbstractSessionImpl(SessionFactoryImpl factory)


	   
		this.factory = factory;
	
Methods Summary
public org.hibernate.QuerycreateQuery(java.lang.String queryString)

		errorIfClosed();
		QueryImpl query = new QueryImpl(
				queryString,
		        this,
		        getHQLQueryPlan( queryString, false ).getParameterMetadata()
		);
		query.setComment( queryString );
		return query;
	
public org.hibernate.SQLQuerycreateSQLQuery(java.lang.String sql)

		errorIfClosed();
		SQLQueryImpl query = new SQLQueryImpl(
				sql,
		        this,
		        factory.getQueryPlanCache().getSQLParameterMetadata( sql )
		);
		query.setComment( "dynamic native SQL query" );
		return query;
	
protected voiderrorIfClosed()

		if ( closed ) {
			throw new SessionException( "Session is closed!" );
		}
	
public org.hibernate.engine.SessionFactoryImplementorgetFactory()

		return factory;
	
protected org.hibernate.engine.query.HQLQueryPlangetHQLQueryPlan(java.lang.String query, boolean shallow)

		return factory.getQueryPlanCache().getHQLQueryPlan( query, shallow, getEnabledFilters() );
	
public org.hibernate.QuerygetNamedQuery(java.lang.String queryName)

		errorIfClosed();
		NamedQueryDefinition nqd = factory.getNamedQuery( queryName );
		final Query query;
		if ( nqd != null ) {
			String queryString = nqd.getQueryString();
			query = new QueryImpl(
					queryString,
			        nqd.getFlushMode(),
			        this,
			        getHQLQueryPlan( queryString, false ).getParameterMetadata()
			);
			query.setComment( "named HQL query " + queryName );
		}
		else {
			NamedSQLQueryDefinition nsqlqd = factory.getNamedSQLQuery( queryName );
			if ( nsqlqd==null ) {
				throw new MappingException( "Named query not known: " + queryName );
			}
			query = new SQLQueryImpl(
					nsqlqd,
			        this,
			        factory.getQueryPlanCache().getSQLParameterMetadata( nsqlqd.getQueryString() )
			);
			query.setComment( "named native SQL query " + queryName );
			nqd = nsqlqd;
		}
		initQuery( query, nqd );
		return query;
	
public org.hibernate.QuerygetNamedSQLQuery(java.lang.String queryName)

		errorIfClosed();
		NamedSQLQueryDefinition nsqlqd = factory.getNamedSQLQuery( queryName );
		if ( nsqlqd==null ) {
			throw new MappingException( "Named SQL query not known: " + queryName );
		}
		Query query = new SQLQueryImpl(
				nsqlqd,
		        this,
		        factory.getQueryPlanCache().getSQLParameterMetadata( nsqlqd.getQueryString() )
		);
		query.setComment( "named native SQL query " + queryName );
		initQuery( query, nsqlqd );
		return query;
	
protected org.hibernate.engine.query.NativeSQLQueryPlangetNativeSQLQueryPlan(org.hibernate.engine.query.sql.NativeSQLQuerySpecification spec)

		return factory.getQueryPlanCache().getNativeSQLQueryPlan( spec );
	
private voidinitQuery(org.hibernate.Query query, org.hibernate.engine.NamedQueryDefinition nqd)

		query.setCacheable( nqd.isCacheable() );
		query.setCacheRegion( nqd.getCacheRegion() );
		if ( nqd.getTimeout()!=null ) query.setTimeout( nqd.getTimeout().intValue() );
		if ( nqd.getFetchSize()!=null ) query.setFetchSize( nqd.getFetchSize().intValue() );
		if ( nqd.getCacheMode() != null ) query.setCacheMode( nqd.getCacheMode() );
		query.setReadOnly( nqd.isReadOnly() );
		if ( nqd.getComment() != null ) query.setComment( nqd.getComment() );
	
public booleanisClosed()

		return closed;
	
public java.util.Listlist(org.hibernate.engine.query.sql.NativeSQLQuerySpecification spec, org.hibernate.engine.QueryParameters queryParameters)

		return listCustomQuery( getNativeSQLQueryPlan( spec ).getCustomQuery(), queryParameters );
	
public org.hibernate.ScrollableResultsscroll(org.hibernate.engine.query.sql.NativeSQLQuerySpecification spec, org.hibernate.engine.QueryParameters queryParameters)

		return scrollCustomQuery( getNativeSQLQueryPlan( spec ).getCustomQuery(), queryParameters );
	
protected voidsetClosed()

		closed = true;