FileDocCategorySizeDatePackage
BasicExecutor.javaAPI DocHibernate 3.2.52730Thu Feb 09 05:37:36 GMT 2006org.hibernate.hql.ast.exec

BasicExecutor

public class BasicExecutor extends AbstractStatementExecutor
Implementation of BasicExecutor.
author
Steve Ebersole

Fields Summary
private static final Log
log
private final org.hibernate.persister.entity.Queryable
persister
private final String
sql
Constructors Summary
public BasicExecutor(org.hibernate.hql.ast.HqlSqlWalker walker, org.hibernate.persister.entity.Queryable persister)


	     
		super( walker, log );
		this.persister = persister;
		try {
			SqlGenerator gen = new SqlGenerator( getFactory() );
			gen.statement( walker.getAST() );
			sql = gen.getSQL();
			gen.getParseErrorHandler().throwQueryException();
		}
		catch ( RecognitionException e ) {
			throw QuerySyntaxException.convert( e );
		}
	
Methods Summary
public intexecute(org.hibernate.engine.QueryParameters parameters, org.hibernate.engine.SessionImplementor session)


		coordinateSharedCacheCleanup( session );

		PreparedStatement st = null;
		RowSelection selection = parameters.getRowSelection();

		try {
			try {
				st = session.getBatcher().prepareStatement( sql );
				Iterator paramSpecifications = getWalker().getParameters().iterator();
				int pos = 1;
				while ( paramSpecifications.hasNext() ) {
					final ParameterSpecification paramSpec = ( ParameterSpecification ) paramSpecifications.next();
					pos += paramSpec.bind( st, parameters, session, pos );
				}
				if ( selection != null ) {
					if ( selection.getTimeout() != null ) {
						st.setQueryTimeout( selection.getTimeout().intValue() );
					}
				}

				return st.executeUpdate();
			}
			finally {
				if ( st != null ) {
					session.getBatcher().closeStatement( st );
				}
			}
		}
		catch( SQLException sqle ) {
			throw JDBCExceptionHelper.convert(
					getFactory().getSQLExceptionConverter(),
			        sqle,
			        "could not execute update query",
			        sql
				);
		}
	
protected org.hibernate.persister.entity.Queryable[]getAffectedQueryables()

		return new Queryable[] { persister };
	
public java.lang.String[]getSqlStatements()

		return new String[] { sql };