void PostProcessInsert(IASTNode insert)
		{
			var insertStatement = (InsertStatement)insert;
			insertStatement.Validate();

			SelectClause selectClause = insertStatement.SelectClause;
			var persister = insertStatement.IntoClause.Queryable;

			if (!insertStatement.IntoClause.IsExplicitIdInsertion)
			{
				// We need to generate ids as part of this bulk insert.
				//
				// Note that this is only supported for sequence-style generators and
				// post-insert-style generators; basically, only in-db generators
				IIdentifierGenerator generator = persister.IdentifierGenerator;
				if (!SupportsIdGenWithBulkInsertion(generator))
				{
					throw new QueryException("can only generate ids as part of bulk insert with either sequence or post-insert style generators");
				}

				IASTNode idSelectExprNode = null;

				var seqGenerator = generator as SequenceGenerator;
				if (seqGenerator != null)
				{
					string seqName = seqGenerator.GeneratorKey();
					string nextval = SessionFactoryHelper.Factory.Dialect.GetSelectSequenceNextValString(seqName);
					idSelectExprNode = ASTFactory.CreateNode(SQL_TOKEN, nextval);
				}
				else
				{
					//Don't need this, because we should never ever be selecting no columns in an insert ... select...
					//and because it causes a bug on DB2
					/*String idInsertString = sessionFactoryHelper.getFactory().getDialect().getIdentityInsertString();
					if ( idInsertString != null ) {
					idSelectExprNode = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, idInsertString );
					}*/
				}

				if (idSelectExprNode != null)
				{
					selectClause.InsertChild(0, idSelectExprNode);

					insertStatement.IntoClause.PrependIdColumnSpec();
				}
			}

			bool includeVersionProperty = persister.IsVersioned && !insertStatement.IntoClause.IsExplicitVersionInsertion && persister.VersionPropertyInsertable;
			if (includeVersionProperty)
			{
				// We need to seed the version value as part of this bulk insert
				IVersionType versionType = persister.VersionType;
				IASTNode versionValueNode;

				if (SessionFactoryHelper.Factory.Dialect.SupportsParametersInInsertSelect)
				{
					versionValueNode = ASTFactory.CreateNode(PARAM, "?");
					IParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification(versionType);
					((ParameterNode)versionValueNode).HqlParameterSpecification = paramSpec;
					_parameters.Insert(0, paramSpec);
				}
				else
				{
					if (IsIntegral(versionType))
					{
						try
						{
							object seedValue = versionType.Seed(null);
							versionValueNode = ASTFactory.CreateNode(SQL_TOKEN, seedValue.ToString());
						}
						catch (Exception t)
						{
							throw new QueryException("could not determine seed value for version on bulk insert [" + versionType + "]", t);
						}
					}
					else if (IsDatabaseGeneratedTimestamp(versionType))
					{
						string functionName = SessionFactoryHelper.Factory.Dialect.CurrentTimestampSQLFunctionName;
						versionValueNode = ASTFactory.CreateNode(SQL_TOKEN, functionName);
					}
					else
					{
						throw new QueryException("cannot handle version type [" + versionType + "] on bulk inserts with dialects not supporting parameters in insert-select statements");
					}
				}

				selectClause.InsertChild(0, versionValueNode);

				insertStatement.IntoClause.PrependVersionColumnSpec();
			}

			if (insertStatement.IntoClause.IsDiscriminated)
			{
				string sqlValue = insertStatement.IntoClause.Queryable.DiscriminatorSQLValue;
				IASTNode discrimValue = ASTFactory.CreateNode(SQL_TOKEN, sqlValue);
				insertStatement.SelectClause.AddChild(discrimValue);
			}
		}
		void PrepareVersioned(IASTNode updateNode, IASTNode versioned)
		{
			var updateStatement = (UpdateStatement)updateNode;
			FromClause fromClause = updateStatement.FromClause;
			if (versioned != null)
			{
				// Make sure that the persister is versioned
				IQueryable persister = fromClause.GetFromElement().Queryable;
				if (!persister.IsVersioned)
				{
					throw new SemanticException("increment option specified for update of non-versioned entity");
				}

				IVersionType versionType = persister.VersionType;
				if (versionType is IUserVersionType)
				{
					throw new SemanticException("user-defined version types not supported for increment option");
				}

				IASTNode eq = ASTFactory.CreateNode(EQ, "=");
				IASTNode versionPropertyNode = GenerateVersionPropertyNode(persister);

				eq.SetFirstChild(versionPropertyNode);

				IASTNode versionIncrementNode;
				if (typeof(DateTime).IsAssignableFrom(versionType.ReturnedClass))
				{
					versionIncrementNode = ASTFactory.CreateNode(PARAM, "?");
					IParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification(versionType);
					((ParameterNode)versionIncrementNode).HqlParameterSpecification = paramSpec;
					Parameters.Insert(0, paramSpec);
				}
				else
				{
					// Not possible to simply re-use the versionPropertyNode here as it causes
					// OOM errors due to circularity :(
					versionIncrementNode = ASTFactory.CreateNode(PLUS, "+");
					versionIncrementNode.SetFirstChild(GenerateVersionPropertyNode(persister));
					versionIncrementNode.AddChild(ASTFactory.CreateNode(IDENT, "1"));
				}

				eq.AddChild(versionIncrementNode);

				EvaluateAssignment(eq, persister, 0);

				IASTNode setClause = updateStatement.SetClause;
				setClause.InsertChild(0, eq);
			}
		}