[hibernate-commits] Hibernate SVN: r20979 - in core/branches/Branch_3_2_4_SP1_CP: grammar and 3 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Oct 14 15:04:26 EDT 2011


Author: stliu
Date: 2011-10-14 15:04:25 -0400 (Fri, 14 Oct 2011)
New Revision: 20979

Added:
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ResultVariableRefNode.java
Removed:
   core/branches/Branch_3_2_4_SP1_CP/build.bat
   core/branches/Branch_3_2_4_SP1_CP/build.sh
   core/branches/Branch_3_2_4_SP1_CP/checkstyle_checks.xml
   core/branches/Branch_3_2_4_SP1_CP/indent.py
   core/branches/Branch_3_2_4_SP1_CP/readme.txt
Modified:
   core/branches/Branch_3_2_4_SP1_CP/build.xml
   core/branches/Branch_3_2_4_SP1_CP/grammar/hql-sql.g
   core/branches/Branch_3_2_4_SP1_CP/grammar/sql-gen.g
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractSelectExpression.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ConstructorNode.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/QueryNode.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectClause.java
   core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectExpression.java
Log:
JBPAPP-6751 HHH-892 HQL parser does not resolve alias in ORDER BY clause

Deleted: core/branches/Branch_3_2_4_SP1_CP/build.bat
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/build.bat	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/build.bat	2011-10-14 19:04:25 UTC (rev 20979)
@@ -1 +0,0 @@
-java -cp "lib/ant-launcher-1.6.5.jar" org.apache.tools.ant.launch.Launcher -lib lib %1 %2 %3 %4 %5

Deleted: core/branches/Branch_3_2_4_SP1_CP/build.sh
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/build.sh	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/build.sh	2011-10-14 19:04:25 UTC (rev 20979)
@@ -1,2 +0,0 @@
-#!/bin/sh
-java -cp "lib/ant-launcher-1.6.5.jar" org.apache.tools.ant.launch.Launcher -lib lib "$@"

Modified: core/branches/Branch_3_2_4_SP1_CP/build.xml
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/build.xml	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/build.xml	2011-10-14 19:04:25 UTC (rev 20979)
@@ -13,55 +13,56 @@
     <!-- ################################################################## -->
 
     <!-- Give user a chance to override without editing this file or typing -D -->
-	<property file="build.properties"/>
-	<property file="${user.home}/.ant.properties"/>
+    <property file="build.properties"/>
+    <property file="${user.home}/.ant.properties"/>
 
-	<!-- Name of project and version, used to create filenames -->
-	<property name="Name" value="Hibernate"/>
-	<property name="name" value="hibernate"/>
-	<property name="name2" value="hibernate3"/>
-	<property name="version.major" value="3"/>
-	<property name="version.minor" value="2"/>
-	<property name="version.micro" value="4"/>
+    <!-- Name of project and version, used to create filenames -->
+    <property name="Name" value="Hibernate"/>
+    <property name="name" value="hibernate"/>
+    <property name="name2" value="hibernate3"/>
+    <property name="version.major" value="3"/>
+    <property name="version.minor" value="2"/>
+    <property name="version.micro" value="4"/>
     <property name="version.qualifier" value="sp1"/>
     <property name="version.cp" value="cp11"/>
-    <property name="version.full" value="${version.major}.${version.minor}.${version.micro}.${version.qualifier}.${version.cp}"/>
+    <property name="version.full"
+              value="${version.major}.${version.minor}.${version.micro}.${version.qualifier}.${version.cp}"/>
     <property name="version.major_minor" value="${version.major}.${version.minor}"/>
     <property name="fullname" value="${name}-${version.full}"/>
 
     <!-- Various SCM-controlled directories -->
-    <property name="dir.src" value="src" />
-    <property name="dir.test" value="test" />
-    <property name="dir.grammar" value="grammar" />
-    <property name="dir.etc" value="etc" />
-    <property name="dir.lib" value="lib" />
-    <property name="dir.jdbc" value="jdbc" />
-	<property name="dir.doc" value="doc"/>
-	<property name="dir.doc.api" value="${dir.doc}/api"/>
-	<property name="dir.eg" value="eg"/>
-    <property name="dir.props" value="${dir.etc}" />
+    <property name="dir.src" value="src"/>
+    <property name="dir.test" value="test"/>
+    <property name="dir.grammar" value="grammar"/>
+    <property name="dir.etc" value="etc"/>
+    <property name="dir.lib" value="lib"/>
+    <property name="dir.jdbc" value="jdbc"/>
+    <property name="dir.doc" value="doc"/>
+    <property name="dir.doc.api" value="${dir.doc}/api"/>
+    <property name="dir.eg" value="eg"/>
+    <property name="dir.props" value="${dir.etc}"/>
 
     <!-- Define the build directory layout -->
-    <property name="dir.build" value="build" />
-    <property name="dir.out.classes" value="${dir.build}/classes" />
-    <property name="dir.out.test-classes" value="${dir.build}/testclasses" />
-    <property name="dir.out.generated-source" value="${dir.build}/gensrc" />
-    <property name="dir.out.antlr-package" value="${dir.out.generated-source}/org/hibernate/hql/antlr" />
-    <property name="dir.out.junit" value="${dir.build}/testout" />
-    <property name="dir.out.junit-reports" value="${dir.build}/test-reports" />
-    <property name="dir.out.perf-test" value="${dir.build}/testout-perf" />
-    <property name="dir.out.db" value="${dir.build}/db" />
-    <property name="dir.out.doc" value="${dir.build}/doc" />
-    <property name="dir.out.eg" value="${dir.build}/eg" />
-    <property name="dir.dist" value="${dir.build}/dist" />
+    <property name="dir.build" value="build"/>
+    <property name="dir.out.classes" value="${dir.build}/classes"/>
+    <property name="dir.out.test-classes" value="${dir.build}/testclasses"/>
+    <property name="dir.out.generated-source" value="${dir.build}/gensrc"/>
+    <property name="dir.out.antlr-package" value="${dir.out.generated-source}/org/hibernate/hql/antlr"/>
+    <property name="dir.out.junit" value="${dir.build}/testout"/>
+    <property name="dir.out.junit-reports" value="${dir.build}/test-reports"/>
+    <property name="dir.out.perf-test" value="${dir.build}/testout-perf"/>
+    <property name="dir.out.db" value="${dir.build}/db"/>
+    <property name="dir.out.doc" value="${dir.build}/doc"/>
+    <property name="dir.out.eg" value="${dir.build}/eg"/>
+    <property name="dir.dist" value="${dir.build}/dist"/>
 
     <!-- Define various operational options -->
-	<property name="javadoc.url.jse" value="http://java.sun.com/j2se/1.5.0/docs/api"/>
-	<property name="javac.debug" value="on"/>
-	<property name="javac.optimize" value="off"/>
-	<property name="javac.target" value="1.5"/>
-	<property name="javac.source" value="1.5"/>
-	<property name="jar.driver" value="${dir.jdbc}/hsqldb.jar"/>
+    <property name="javadoc.url.jse" value="http://java.sun.com/j2se/1.5.0/docs/api"/>
+    <property name="javac.debug" value="on"/>
+    <property name="javac.optimize" value="off"/>
+    <property name="javac.target" value="1.5"/>
+    <property name="javac.source" value="1.5"/>
+    <property name="jar.driver" value="${dir.jdbc}/hsqldb.jar"/>
 
     <!-- JAR and dist file names -->
     <property name="jar.name" value="${name2}"/>
@@ -71,55 +72,59 @@
 
     <!-- fileset definition for the lib directory -->
     <fileset id="fs.lib" dir="${dir.lib}">
-        <include name="**/*.jar" />
+        <include name="**/*.jar"/>
     </fileset>
+    <fileset id="fs.lib.test" dir="${dir.lib}">
+        <include name="**/*.jar"/>
+        <exclude name="**/ant-*.jar"/>
+    </fileset>
     <path id="path.lib">
-        <fileset refid="fs.lib" />
-	</path>
+        <fileset refid="fs.lib"/>
+    </path>
 
     <!-- fileset definition for the "supported" jars for distribution -->
     <fileset id="fs.lib.dist" dir="${dir.lib}">
-        <include name="**/javassist.jar" />
-        <include name="**/cglib.jar" />
-        <include name="**/asm.jar" />
-        <include name="**/asm-attrs.jar" />
-        <include name="**/commons-collections.jar" />
-        <include name="**/commons-logging.jar" />
-        <include name="**/apache-1.1.txt" />
-        <include name="**/apache-2.0.txt" />
-        <include name="**/antlr.jar" />
-        <include name="**/antlr.txt" />
-        <include name="**/dom4j.jar" />
-        <include name="**/jaxen.jar" />
-        <include name="**/jboss-j2ee.jar" />
-        <include name="**/jboss-cache-jdk50.jar" />
-        <include name="**/concurrent.jar" />
-        <include name="**/jboss-common.jar" />
-        <include name="**/jboss-jmx.jar" />
-        <include name="**/jboss-minimal.jar" />
-        <include name="**/jboss-system.jar" />
-        <include name="**/jgroups.jar" />
-        <include name="**/version-dist.properties" />
+        <include name="**/javassist.jar"/>
+        <include name="**/cglib.jar"/>
+        <include name="**/asm.jar"/>
+        <include name="**/asm-attrs.jar"/>
+        <include name="**/commons-collections.jar"/>
+        <include name="**/commons-logging.jar"/>
+        <include name="**/apache-1.1.txt"/>
+        <include name="**/apache-2.0.txt"/>
+        <include name="**/antlr.jar"/>
+        <include name="**/antlr.txt"/>
+        <include name="**/dom4j.jar"/>
+        <include name="**/jaxen.jar"/>
+        <include name="**/jboss-j2ee.jar"/>
+        <include name="**/jboss-cache-jdk50.jar"/>
+        <include name="**/concurrent.jar"/>
+        <include name="**/jboss-common.jar"/>
+        <include name="**/jboss-jmx.jar"/>
+        <include name="**/jboss-minimal.jar"/>
+        <include name="**/jboss-system.jar"/>
+        <include name="**/jgroups.jar"/>
+        <include name="**/version-dist.properties"/>
     </fileset>
 
     <!-- path definition for the JDBC driver(s) -->
     <path id="path.jdbc">
         <!-- By default include everything in the ${dir.jdbc} directory -->
         <fileset dir="${dir.jdbc}">
-            <include name="**/*.jar" />
-            <include name="**/*.zip" />
+            <include name="**/*.jar"/>
+            <include name="**/*.zip"/>
         </fileset>
         <!-- And the explicitly defined jar.driver property (used by the CC scripts) -->
         <pathelement path="${jar.driver}"/>
     </path>
     <!-- allows external definition of the JDBC classpath fragment -->
-    <property name="hibernate.test.jdbc.fs.importFile" value="doNotImport" />
-    <import file="${hibernate.test.jdbc.fs.importFile}" optional="true" />
+    <property name="hibernate.test.jdbc.fs.importFile" value="doNotImport"/>
+    <import file="${hibernate.test.jdbc.fs.importFile}" optional="true"/>
 
     <!-- patternset for insturmentation-eligible resources -->
-	<patternset id="ps.instrument.domain">
-		<include name="org/hibernate/test/instrument/domain/*" />
-        <exclude name="**/*.hbm.xml" />
+    <patternset id="ps.instrument.domain">
+        <include name="org/hibernate/test/instrument/domain/*"/>
+        <exclude name="**/*.hbm.xml"/>
     </patternset>
 
 
@@ -127,18 +132,6 @@
     <!-- ############################# Tasks ############################## -->
     <!-- ################################################################## -->
 
-    <taskdef name="splash" classname="org.apache.tools.ant.taskdefs.optional.splash.SplashTask">
-        <classpath refid="path.lib"/>
-    </taskdef>
-
-	<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
-		<classpath refid="path.lib"/>
-	</taskdef>
-
-	<taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator">
-		<classpath refid="path.lib"/>
-	</taskdef>
-
     <!-- ################################################################## -->
     <!-- ############################ Targets ############################# -->
     <!-- ################################################################## -->
@@ -146,78 +139,76 @@
     <!-- Various 'preparation targets -->
 
     <target name="splash" unless="nosplash" description="Display the logo">
-		<property name="splash.dir" location="."/>
-		<splash imageurl="file:${splash.dir}/hibernate_logo.gif" showduration="0"/>
-	</target>
+        <property name="splash.dir" location="."/>
+        <splash imageurl="file:${splash.dir}/hibernate_logo.gif" showduration="0"/>
+    </target>
 
-	<target name="init" depends="splash" description="Initialize the build">
-		<tstamp>
-			<format property="now" pattern="yyyy-MM-dd hh:mm:ss"/>
-		</tstamp>
-		<echo message="Build ${Name}-${version.full} (${now})"/>
-		<echo message="JDK version: ${ant.java.version}"/>
-	</target>
+    <target name="init" depends="splash" description="Initialize the build">
+        <tstamp>
+            <format property="now" pattern="yyyy-MM-dd hh:mm:ss"/>
+        </tstamp>
+        <echo message="Build ${Name}-${version.full} (${now})"/>
+        <echo message="JDK version: ${ant.java.version}"/>
+    </target>
 
 
     <!-- Various 'clean' targets -->
 
     <target name="clean" depends="init" description="Cleans up build directories">
-		<delete dir="${dir.build}"/>
-	</target>
+        <delete dir="${dir.build}"/>
+    </target>
 
-	<target name="cleantestdb" depends="init" description="Clean up the test file-based database directories">
-		<delete dir="${dir.out.db}" />
-	</target>
+    <target name="cleantestdb" depends="init" description="Clean up the test file-based database directories">
+        <delete dir="${dir.out.db}"/>
+    </target>
 
     <target name="init.antlr" depends="init" unless="antlr.isUpToDate" description="Check ANTLR dependencies.">
         <uptodate property="antlr.isUpToDate" targetfile="${dir.out.antlr-package}/.antlr_run">
-			<srcfiles dir="${dir.grammar}" includes="*.g"/>
-		</uptodate>
-	</target>
+            <srcfiles dir="${dir.grammar}" includes="*.g"/>
+        </uptodate>
+    </target>
 
-	<target name="antlr" depends="init.antlr" unless="antlr.isUpToDate" description="Generate ANTLR parsers.">
-        <taskdef name="antlrtask" classname="org.apache.tools.ant.taskdefs.optional.ANTLR">
-            <classpath>
-                <fileset dir="${dir.lib}">
-                    <include name="ant-antlr-*.jar"/>
-                    <include name="antlr-*.jar"/>
-                </fileset>
-            </classpath>
-        </taskdef>
-        <mkdir dir="${dir.out.antlr-package}" />
-		<antlrtask target="${dir.grammar}/hql.g" outputdirectory="${dir.out.antlr-package}" />
-		<antlrtask target="${dir.grammar}/hql-sql.g" outputdirectory="${dir.out.antlr-package}" />
-		<antlrtask target="${dir.grammar}/sql-gen.g" outputdirectory="${dir.out.antlr-package}" />
-		<touch file="${dir.out.antlr-package}/.antlr_run"/>
-	</target>
+    <target name="antlr" depends="init.antlr" unless="antlr.isUpToDate" description="Generate ANTLR parsers.">
+        <mkdir dir="${dir.out.antlr-package}"/>
+        <antlr target="${dir.grammar}/hql.g" outputdirectory="${dir.out.antlr-package}">
+            <classpath refid="path.lib"/>
+        </antlr>
+        <antlr target="${dir.grammar}/hql-sql.g" outputdirectory="${dir.out.antlr-package}">
+            <classpath refid="path.lib"/>
+        </antlr>
+        <antlr target="${dir.grammar}/sql-gen.g" outputdirectory="${dir.out.antlr-package}">
+            <classpath refid="path.lib"/>
+        </antlr>
+        <touch file="${dir.out.antlr-package}/.antlr_run"/>
+    </target>
 
-	<target name="cleanantlr" depends="init" description="Clean up the generated ANTLR parsers.">
-		<delete dir="${dir.out.antlr-package}"/>
-	</target>
+    <target name="cleanantlr" depends="init" description="Clean up the generated ANTLR parsers.">
+        <delete dir="${dir.out.antlr-package}"/>
+    </target>
 
-	<target name="antlr.regen" depends="init,cleanantlr,antlr" description="Regenerate all ANTLR generated code." />
+    <target name="antlr.regen" depends="init,cleanantlr,antlr" description="Regenerate all ANTLR generated code."/>
 
     <target name="antlr.bnf" depends="init" description="Generate BNF diagram for HQL">
-       <mkdir dir="${dir.out.doc}/other"/>
-       <property name="bnf.grammar" location="${dir.grammar}/hql.g"/>
+        <mkdir dir="${dir.out.doc}/other"/>
+        <property name="bnf.grammar" location="${dir.grammar}/hql.g"/>
 
-       <java dir="${dir.out.doc}/other" classname="net.mark_malakanov.sdg2.Main" classpathref="path.lib" fork="true">
-           <jvmarg line="-Xmx512M"/>
-           <arg line="-blind"/>
-           <arg line="-savehtml hql-bnf.html"/>
-           <arg line="-savehtmltitle Hibernate ${version.full} HQL"/>
-           <arg line="${bnf.grammar}"/>
-       </java>
+        <java dir="${dir.out.doc}/other" classname="net.mark_malakanov.sdg2.Main" classpathref="path.lib" fork="true">
+            <jvmarg line="-Xmx512M"/>
+            <arg line="-blind"/>
+            <arg line="-savehtml hql-bnf.html"/>
+            <arg line="-savehtmltitle Hibernate ${version.full} HQL"/>
+            <arg line="${bnf.grammar}"/>
+        </java>
     </target>
 
 
     <!-- Compilation targets -->
 
     <target name="compile" depends="init,antlr" unless="classes.isUpToDate" description="Compile the Java source code">
-		<mkdir dir="${dir.out.classes}"/>
-		<available classname="org.eclipse.core.launcher.Main" property="build.compiler"
+        <mkdir dir="${dir.out.classes}"/>
+        <available classname="org.eclipse.core.launcher.Main" property="build.compiler"
                    value="org.eclipse.jdt.core.JDTCompilerAdapter" classpath="${java.class.path}"/>
-		<javac destdir="${dir.out.classes}"
+        <javac destdir="${dir.out.classes}"
                classpathref="path.lib"
                debug="${javac.debug}"
                optimize="${javac.optimize}"
@@ -225,86 +216,90 @@
                source="${javac.source}"
                nowarn="on">
             <src path="${dir.src}"/>
-			<src path="${dir.out.generated-source}"/>
-		</javac>
-		<copy todir="${dir.out.classes}">
-			<fileset dir="${dir.src}">
-                <include name="**/*.dtd" />
-                <include name="**/*.xml" />
-                <include name="**/*.xslt" />
-			</fileset>
-		</copy>
-	</target>
+            <src path="${dir.out.generated-source}"/>
+        </javac>
+        <copy todir="${dir.out.classes}">
+            <fileset dir="${dir.src}">
+                <include name="**/*.dtd"/>
+                <include name="**/*.xml"/>
+                <include name="**/*.xslt"/>
+            </fileset>
+        </copy>
+    </target>
 
-	<target name="compiletest" depends="compile" unless="test-classes.isUpToDate" description="Compile the tests">
-		<mkdir dir="${dir.out.test-classes}"/>
-		<available classname="org.eclipse.core.launcher.Main" property="build.compiler"
+    <target name="compiletest" depends="compile" unless="test-classes.isUpToDate" description="Compile the tests">
+        <mkdir dir="${dir.out.test-classes}"/>
+        <available classname="org.eclipse.core.launcher.Main" property="build.compiler"
                    value="org.eclipse.jdt.core.JDTCompilerAdapter" classpath="${java.class.path}"/>
-		<javac destdir="${dir.out.test-classes}"
+        <javac destdir="${dir.out.test-classes}"
                debug="${javac.debug}"
                optimize="${javac.optimize}"
                target="${javac.target}"
                source="${javac.source}"
                nowarn="on">
-			<classpath>
-				<path refid="path.lib" />
-				<pathelement path="${dir.out.classes}" />
-			</classpath>
-            <src path="${dir.test}" />
+            <classpath>
+                <path refid="path.lib"/>
+                <pathelement path="${dir.out.classes}"/>
+            </classpath>
+            <src path="${dir.test}"/>
         </javac>
-		<copy todir="${dir.out.test-classes}">
-			<fileset dir="${dir.test}">
-                <include name="**/*.xml" />
-                <include name="**/*.properties" />
-			</fileset>
-		</copy>
-	</target>
+        <copy todir="${dir.out.test-classes}">
+            <fileset dir="${dir.test}">
+                <include name="**/*.xml"/>
+                <include name="**/*.properties"/>
+            </fileset>
+        </copy>
+    </target>
 
 
     <!-- testsuite targets -->
 
-	<target name="junitreport" depends="splash,junit" description="Run tests and create JUnit report (requires driver.jar property)">
-        <delete dir="${dir.out.junit-reports}" />
-        <mkdir dir="${dir.out.junit-reports}" />
+    <target name="junitreport"
+            depends="splash,junit"
+            description="Run tests and create JUnit report (requires driver.jar property)">
+        <delete dir="${dir.out.junit-reports}"/>
+        <mkdir dir="${dir.out.junit-reports}"/>
         <junitreport todir="${dir.out.junit-reports}">
-			<fileset dir="${dir.out.junit}">
-				<include name="TEST-*.xml"/>
-			</fileset>
-			<report format="frames" todir="${dir.out.junit-reports}"/>
-		</junitreport>
-	</target>
+            <fileset dir="${dir.out.junit}">
+                <include name="TEST-*.xml"/>
+            </fileset>
+            <report format="frames" todir="${dir.out.junit-reports}"/>
+        </junitreport>
+    </target>
 
-	<target name="junitreport-dist" depends="splash,prepare-dist,junitreport" description="Run tests using distribution jars and create JUnit report (requires driver.jar property)" />
+    <target name="junitreport-dist"
+            depends="splash,prepare-dist,junitreport"
+            description="Run tests using distribution jars and create JUnit report (requires driver.jar property)"/>
 
-	<target name="prepare-dist" depends="init" description="Unzip jar and test jar to be use in distribution">
-		<mkdir dir="${dir.build}" />
-		<delete dir="${dir.out.classes}"/>
-		<mkdir dir="${dir.out.classes}" />		
-		<delete dir="${dir.out.test-classes}"/>
-		<mkdir dir="${dir.out.test-classes}" />
-		<unzip src="${basedir}/${jar.name}.jar" dest="${dir.out.classes}" />
-		<unzip src="${basedir}/${testjar.name}.jar" dest="${dir.out.test-classes}" />
-		<delete dir="${dir.out.generated-source}" />		
-		<available file="${dir.out.classes}/org/hibernate/hql/antlr"
-			type="dir" 
-			property="antlr.isUpToDate"/>
-		<available file="${dir.out.classes}/org/hibernate"
-			type="dir" 
-			property="classes.isUpToDate"/>
-		<available file="${dir.out.test-classes}/org/hibernate/test"
-			type="dir" 
-			property="test-classes.isUpToDate"/>
-		<property name="test-classes.isFromJar" value="$test-classes.isUpToDate" />
-		<echo message="antlr.isUpToDate=${antlr.isUpToDate}" />
-		<echo message="classes.isUpToDate=${classes.isUpToDate}" />
-		<echo message="test-classes.isUpToDate=${test-classes.isUpToDate}" />
-	</target>
+    <target name="prepare-dist" depends="init" description="Unzip jar and test jar to be use in distribution">
+        <mkdir dir="${dir.build}"/>
+        <delete dir="${dir.out.classes}"/>
+        <mkdir dir="${dir.out.classes}"/>
+        <delete dir="${dir.out.test-classes}"/>
+        <mkdir dir="${dir.out.test-classes}"/>
+        <unzip src="${basedir}/${jar.name}.jar" dest="${dir.out.classes}"/>
+        <unzip src="${basedir}/${testjar.name}.jar" dest="${dir.out.test-classes}"/>
+        <delete dir="${dir.out.generated-source}"/>
+        <available file="${dir.out.classes}/org/hibernate/hql/antlr"
+                   type="dir"
+                   property="antlr.isUpToDate"/>
+        <available file="${dir.out.classes}/org/hibernate"
+                   type="dir"
+                   property="classes.isUpToDate"/>
+        <available file="${dir.out.test-classes}/org/hibernate/test"
+                   type="dir"
+                   property="test-classes.isUpToDate"/>
+        <property name="test-classes.isFromJar" value="$test-classes.isUpToDate"/>
+        <echo message="antlr.isUpToDate=${antlr.isUpToDate}"/>
+        <echo message="classes.isUpToDate=${classes.isUpToDate}"/>
+        <echo message="test-classes.isUpToDate=${test-classes.isUpToDate}"/>
+    </target>
 
     <target name="junit" depends="junit.prepare">
         <sequential>
-            <antcall target="junit.standard" />
-            <antcall target="junit.instrument.cglib" />
-            <antcall target="junit.instrument.javassist" />
+            <antcall target="junit.standard"/>
+            <antcall target="junit.instrument.cglib"/>
+            <antcall target="junit.instrument.javassist"/>
         </sequential>
     </target>
 
@@ -313,215 +308,121 @@
         <mkdir dir="${dir.out.junit}"/>
     </target>
 
-    <target name="junit.standard" depends="junit.prepare" description="Run the test suite (requires driver.jar property)">
+    <target name="junit.standard"
+            depends="junit.prepare"
+            description="Run the test suite (requires driver.jar property)">
         <path id="selector.classpath">
             <!--
                 the selector needs all of this because it actually gets the suite
                 from AllTests and then performs the filtering based on that
             -->
-            <fileset refid="fs.lib" />
-            <path refid="path.jdbc" />
+            <fileset refid="fs.lib.test"/>
+            <path refid="path.jdbc"/>
             <pathelement path="${dir.out.classes}"/>
             <pathelement path="${dir.out.test-classes}"/>
             <pathelement path="${dir.props}"/>
         </path>
 
-        <junit printsummary="yes" dir="${basedir}" maxmemory="256M" fork="yes" forkmode="perBatch">
-			<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
-			<classpath>
-                <fileset refid="fs.lib" />
-            <path refid="path.jdbc" />
+        <junit printsummary="on" dir="${basedir}" maxmemory="256M" fork="yes" forkmode="perBatch">
+            <jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
+            <classpath>
+                <fileset refid="fs.lib.test"/>
+                <path refid="path.jdbc"/>
                 <pathelement path="${dir.out.classes}"/>
                 <pathelement path="${dir.out.test-classes}"/>
                 <pathelement path="${dir.props}"/>
-			</classpath>
-			<formatter type="plain"/>
-			<formatter type="xml"/>
+            </classpath>
+            <formatter type="plain"/>
+            <formatter type="xml"/>
             <batchtest todir="${dir.out.junit}" haltonfailure="no">
                 <fileset dir="${dir.out.test-classes}">
-                    <include name="org/hibernate/test/**/*Test.class" />
+                    <include name="org/hibernate/test/**/*Test.class"/>
                     <!-- exclude the build-time instrumentation tasks as we will be running them manually shortly -->
-                    <exclude name="org/hibernate/test/instrument/buildtime/*" />
+                    <exclude name="org/hibernate/test/instrument/buildtime/*"/>
                     <!--custom selector to make sure only those tests in the AllTests suite get picked up here -->
-                    <custom classname="org.hibernate.test.TestSelector" classpathref="selector.classpath" />
-				</fileset>
-			</batchtest>
-		</junit>
+                    <custom classname="org.hibernate.test.TestSelector" classpathref="selector.classpath"/>
+                </fileset>
+            </batchtest>
+        </junit>
     </target>
 
-    <target name="junit.instrument" depends="junit.prepare,junit.instrument.cglib,junit.instrument.javassist" />
+    <target name="junit.instrument" depends="junit.prepare,junit.instrument.cglib,junit.instrument.javassist"/>
 
     <target name="junit.instrument.cglib" depends="instrument.cglib">
         <mkdir dir="${dir.out.junit}"/>
-		<junit printsummary="yes" maxmemory="256M" fork="yes">
-			<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
-			<classpath>
-                <fileset refid="fs.lib" />
-                <path refid="path.jdbc" />
+        <junit printsummary="yes" maxmemory="256M" fork="yes">
+            <jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
+            <classpath>
+                <fileset refid="fs.lib.test"/>
+                <path refid="path.jdbc"/>
                 <pathelement path="${dir.out.classes}"/>
                 <pathelement path="${dir.out.test-classes}"/>
                 <pathelement path="${dir.props}"/>
-			</classpath>
-			<formatter type="plain"/>
-			<formatter type="xml"/>
+            </classpath>
+            <formatter type="plain"/>
+            <formatter type="xml"/>
             <test name="org.hibernate.test.instrument.buildtime.InstrumentTest"
-                    outfile="TEST-CGLIB-org.hibernate.test.instrument.buildtime.InstrumentTest"
-                    todir="${dir.out.junit}"
-                    haltonerror="false"
-                    haltonfailure="false" />
-		</junit>
+                  outfile="TEST-CGLIB-org.hibernate.test.instrument.buildtime.InstrumentTest"
+                  todir="${dir.out.junit}"
+                  haltonerror="false"
+                  haltonfailure="false"/>
+        </junit>
     </target>
 
     <target name="junit.instrument.javassist" depends="instrument.javassist">
         <mkdir dir="${dir.out.junit}"/>
-		<junit printsummary="yes" maxmemory="256M" fork="yes">
-			<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
-			<classpath>
-                <fileset refid="fs.lib" />
-                <path refid="path.jdbc" />
+        <junit printsummary="yes" maxmemory="256M" fork="yes">
+            <jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
+            <classpath>
+                <fileset refid="fs.lib.test"/>
+                <path refid="path.jdbc"/>
                 <pathelement path="${dir.out.classes}"/>
                 <pathelement path="${dir.out.test-classes}"/>
                 <pathelement path="${dir.props}"/>
-			</classpath>
-			<formatter type="plain"/>
-			<formatter type="xml"/>
+            </classpath>
+            <formatter type="plain"/>
+            <formatter type="xml"/>
             <test name="org.hibernate.test.instrument.buildtime.InstrumentTest"
-                    outfile="TEST-JAVASSIST-org.hibernate.test.instrument.buildtime.InstrumentTest"
-                    todir="${dir.out.junit}"
-                    haltonerror="false"
-                    haltonfailure="false" />
-		</junit>
+                  outfile="TEST-JAVASSIST-org.hibernate.test.instrument.buildtime.InstrumentTest"
+                  todir="${dir.out.junit}"
+                  haltonerror="false"
+                  haltonfailure="false"/>
+        </junit>
     </target>
 
     <!-- Run a single unit test. -->
-	<target name="junitsingle" depends="cleantestdb,compiletest" description="Run a single test suite (requires testname and jar.driver properties)">
+    <target name="junitsingle"
+            depends="cleantestdb,compiletest"
+            description="Run a single test suite (requires testname and jar.driver properties)">
         <delete dir="${dir.out.junit}"/>
         <mkdir dir="${dir.out.junit}"/>
         <junit printsummary="yes" fork="yes" haltonfailure="yes" dir="${basedir}">
-			<classpath>
-                <fileset refid="fs.lib" />
-                <path refid="path.jdbc" />
+            <classpath>
+                <fileset refid="fs.lib.test"/>
+                <path refid="path.jdbc"/>
                 <pathelement path="${dir.out.classes}"/>
                 <pathelement path="${dir.out.test-classes}"/>
                 <pathelement path="${dir.props}"/>
-			</classpath>
-			<formatter type="plain"/>
-			<formatter type="xml"/>
-			<test fork="yes" todir="${dir.out.junit}" haltonfailure="no" name="${testname}"/>
-		</junit>
-	</target>
-
-    <target name="perf" depends="cleantestdb,compiletest" description="Run the performance tests">
-        <delete dir="${dir.out.perf-test}"/>
-        <mkdir dir="${dir.out.perf-test}"/>
-		<junit printsummary="yes" maxmemory="256M" fork="yes" haltonfailure="yes" dir="${basedir}">
-			<jvmarg value="-Dhibernate.test.validatefailureexpected=${hibernate.test.validatefailureexpected}"/>
-			<classpath>
-                <fileset refid="fs.lib" />
-                <path refid="path.jdbc" />
-                <pathelement path="${dir.out.classes}"/>
-                <pathelement path="${dir.out.test-classes}"/>
-                <pathelement path="${dir.props}"/>
-			</classpath>
-			<formatter type="plain"/>
-			<test name="org.hibernate.test.legacy.NewPerformanceTest" todir="${dir.out.perf-test}" haltonfailure="no"/>
-			<test name="org.hibernate.test.legacy.NewerPerformanceTest" todir="${dir.out.perf-test}" haltonfailure="no"/>
-			<test name="org.hibernate.test.legacy.PerformanceTest" todir="${dir.out.perf-test}" haltonfailure="no"/>
-		</junit>
-	</target>
-
-	<target name="eg" depends="prepare-dist" description="Compile and run the simple example">
-		<!-- works only in distribution, not in SVN tree; see 'eg.inline' target -->
-        <mkdir dir="${dir.out.eg}" />
-
-        <available classname="org.eclipse.core.launcher.Main"
-			    property="build.compiler"
-			    value="org.eclipse.jdt.core.JDTCompilerAdapter"
-			    classpath="${java.class.path}"/>
-		<javac  srcdir="${dir.eg}"
-			    destdir="${dir.out.eg}"
-			    debug="${javac.debug}"
-			    optimize="${javac.optimize}"
-                target="${javac.target}"
-                source="${javac.source}"
-			    nowarn="on">
-			<classpath>
-				<pathelement path="${dir.build}/${jar.name}.jar"/>
-				<pathelement path="${basedir}/${jar.name}.jar"/>
-                <fileset refid="fs.lib" />
-			</classpath>
-		</javac>
-
-        <copy todir="${dir.out.eg}">
-            <fileset dir="${dir.eg}">
-                <include name="**/*.xml" />
-            </fileset>
-        </copy>
-
-		<echo message="remember to place your JDBC driver in the lib directory"/>
-        <java classname="org.hibernate.auction.Main" fork="true" failonerror="true">
-			<classpath>
-                <fileset refid="fs.lib" />
-				<pathelement path="${dir.out.eg}" />
-				<pathelement path="${basedir}/${jar.name}.jar"/>
-				<pathelement path="${dir.etc}" />
-			</classpath>
-		</java>
-
-        <echo message="Please follow the Getting Started road map: http://www.hibernate.org/152.html"/>
-	</target>
-
-    <target name="eg.inline" depends="jar" description="Compile and run the simple example utilizing the build structure">
-        <mkdir dir="${dir.out.eg}" />
-
-        <available classname="org.eclipse.core.launcher.Main"
-			    property="build.compiler"
-			    value="org.eclipse.jdt.core.JDTCompilerAdapter"
-			    classpath="${java.class.path}"/>
-		<javac  srcdir="${dir.eg}"
-			    destdir="${dir.out.eg}"
-			    debug="${javac.debug}"
-			    optimize="${javac.optimize}"
-                target="${javac.target}"
-                source="${javac.source}"
-			    nowarn="on">
-			<classpath>
-				<pathelement path="${dir.build}/${jar.name}.jar"/>
-                <fileset refid="fs.lib" />
-			</classpath>
-		</javac>
-
-        <copy todir="${dir.out.eg}">
-            <fileset dir="${dir.eg}">
-                <include name="**/*.xml" />
-            </fileset>
-        </copy>
-
-		<java classname="org.hibernate.auction.Main" fork="true" failonerror="true">
-			<classpath>
-                <fileset refid="fs.lib" />
-                <path refid="path.jdbc" />
-				<pathelement path="${dir.out.eg}" />
-				<pathelement path="${dir.build}/${jar.name}.jar"/>
-				<pathelement path="${dir.props}" />
-			</classpath>
-		</java>
+            </classpath>
+            <formatter type="plain"/>
+            <formatter type="xml"/>
+            <test fork="yes" todir="${dir.out.junit}" haltonfailure="no" name="${testname}"/>
+        </junit>
     </target>
 
-
     <!-- Instrumentation tasks -->
 
     <target name="instrument.clean">
         <delete>
             <fileset dir="${dir.out.test-classes}">
-                <patternset refid="ps.instrument.domain" />
+                <patternset refid="ps.instrument.domain"/>
             </fileset>
         </delete>
     </target>
 
 
     <target name="instrument.prepare-from-testjar" depends="instrument.clean" if="test-classes.isFromJar">
-        <unzip src="${basedir}/${testjar.name}.jar" dest="${dir.out.test-classes}" />
+        <unzip src="${basedir}/${testjar.name}.jar" dest="${dir.out.test-classes}"/>
     </target>
 
     <target name="instrument.prepare" depends="instrument.prepare-from-testjar" unless="test-classes.isFromJar">
@@ -533,89 +434,59 @@
                target="${javac.target}"
                source="${javac.source}"
                nowarn="on">
-	    <classpath>
-                <path refid="path.lib" />
-                <pathelement path="${dir.out.classes}" />
+            <classpath>
+                <path refid="path.lib"/>
+                <pathelement path="${dir.out.classes}"/>
             </classpath>
-            <src path="${dir.test}" />
-            <patternset refid="ps.instrument.domain" />
+            <src path="${dir.test}"/>
+            <patternset refid="ps.instrument.domain"/>
         </javac>
     </target>
 
 
-    <target name="instrument.cglib" depends="instrument.prepare,compiletest" description="Performs cglib-based instrumentation">
+    <target name="instrument.cglib"
+            depends="instrument.prepare,compiletest"
+            description="Performs cglib-based instrumentation">
         <taskdef name="instrument" classname="org.hibernate.tool.instrument.cglib.InstrumentTask">
             <classpath path="${dir.out.classes}"/>
             <classpath refid="path.lib"/>
         </taskdef>
         <instrument verbose="true">
             <fileset dir="${dir.out.test-classes}">
-                <patternset refid="ps.instrument.domain" />
+                <patternset refid="ps.instrument.domain"/>
             </fileset>
         </instrument>
     </target>
 
-    <target name="instrument.javassist" depends="instrument.prepare,compiletest" description="Performs javassist-based instrumentation">
+    <target name="instrument.javassist"
+            depends="instrument.prepare,compiletest"
+            description="Performs javassist-based instrumentation">
         <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
             <classpath path="${dir.out.classes}"/>
             <classpath refid="path.lib"/>
         </taskdef>
         <instrument verbose="true">
             <fileset dir="${dir.out.test-classes}">
-                <patternset refid="ps.instrument.domain" />
+                <patternset refid="ps.instrument.domain"/>
             </fileset>
         </instrument>
     </target>
 
     <!-- Distribution related targets -->
 
-	<target name="versioncheck" description="Check version.properties up against lib directory">
-        <!-- If versioncheck fails two things can be "out-of-sync":
+    <target name="jar" depends="compile" description="Build the distribution .jar file">
+        <mkdir dir="${dir.build}"/>
 
-            1) '<libraryname> not found in fileset of libraries!' means that version.properties
-            defines a library, but this library is not in the lib directory.  Resolution: add
-            the library to the lib directory or remove the definiton from version.properties
-
-            2) '<filename> not listed in version.properties' means a file was found in the lib
-            directory, but not in version.properties; Resolution: add the library to the
-            version.properties or remove the library from the libraries.
-         -->
-		<taskdef classname="versioncheck.VersionCheckTask" classpath="${dir.lib}/versioncheck.jar" name="versioncheck"/>
-		<mkdir dir="${dir.build}/versioncheck" />
-		<versioncheck versionfile="${dir.lib}/version.properties" output="${dir.build}/versioncheck/_README.txt">
-			<fileset dir="${dir.lib}">
-				<include name="**/*.zip" />
-				<include name="**/*.jar" />
-			</fileset>
-		</versioncheck>
-		<mkdir dir="${dir.build}/versioncheck-dist" />
-		<copy todir="${dir.build}/versioncheck-dist" >
-        		<fileset refid="fs.lib.dist" />
-    		</copy>
-		<move file="${dir.build}/versioncheck-dist/version-dist.properties"
-			tofile="${dir.build}/versioncheck-dist/version.properties" />
-		<versioncheck versionfile="${dir.build}/versioncheck-dist/version.properties" 
-			output="${dir.build}/versioncheck-dist/_README.txt" >
-			<fileset dir="${dir.build}/versioncheck-dist/" >
-				<include name="**/*.zip" />
-				<include name="**/*.jar" />
-			</fileset>
-		</versioncheck>
-	</target>
-
-	<target name="jar" depends="compile" description="Build the distribution .jar file">
-		<mkdir dir="${dir.build}"/>
-
         <jar jarfile="${dir.build}/${jar.name}.jar" basedir="${dir.out.classes}">
-			<include name="org/hibernate/**/*.class" />
+            <include name="org/hibernate/**/*.class"/>
             <include name="org/hibernate/*.dtd"/>
-			<manifest>
+            <manifest>
                 <attribute name="Implementation-Title" value="Hibernate3"/>
                 <attribute name="Implementation-Version" value="${version.full}"/>
                 <attribute name="Implementation-Vendor" value="hibernate.org"/>
                 <attribute name="Hibernate-Version" value="${version.full}"/>
-			</manifest>
-		</jar>
+            </manifest>
+        </jar>
 
         <!-- currently for testing *only* -->
         <jar jarfile="${dir.build}/hibernate3-client.jar">
@@ -634,160 +505,139 @@
                 <include name="org/hibernate/util/**"/>
                 <include name="org/hibernate/proxy/**"/>
             </zipfileset>
-			<manifest>
+            <manifest>
                 <attribute name="Implementation-Title" value="Hibernate3 Client"/>
                 <attribute name="Implementation-Version" value="${version.full}"/>
                 <attribute name="Implementation-Vendor" value="hibernate.org"/>
                 <attribute name="Hibernate-Version" value="${version.full}"/>
-			</manifest>
+            </manifest>
         </jar>
     </target>
 
-	<target name="testjar" depends="compiletest" description="Build the distribution test .jar file">
-		<mkdir dir="${dir.build}"/>
-		<jar jarfile="${dir.build}/${testjar.name}.jar" basedir="${dir.out.test-classes}">
-			<include name="org/hibernate/**/*" />
+    <target name="testjar" depends="compiletest" description="Build the distribution test .jar file">
+        <mkdir dir="${dir.build}"/>
+        <jar jarfile="${dir.build}/${testjar.name}.jar" basedir="${dir.out.test-classes}">
+            <include name="org/hibernate/**/*"/>
 
-			<manifest>
-				<attribute name="Implementation-Title" value="Hibernate3-test"/>
-				<attribute name="Implementation-Version" value="${version.full}"/>
-				<attribute name="Implementation-Vendor" value="hibernate.org"/>
-				<attribute name="Hibernate-Version" value="${version.full}"/>
-			</manifest>
-		</jar>
-	</target>
+            <manifest>
+                <attribute name="Implementation-Title" value="Hibernate3-test"/>
+                <attribute name="Implementation-Version" value="${version.full}"/>
+                <attribute name="Implementation-Vendor" value="hibernate.org"/>
+                <attribute name="Hibernate-Version" value="${version.full}"/>
+            </manifest>
+        </jar>
+    </target>
 
-	<target name="dist" depends="init,versioncheck,jar,testjar,javadoc"
-		description="Build everything and package">
-		<mkdir dir="${dir.dist}" />
+    <target name="dist" depends="init,jar,testjar,javadoc"
+            description="Build everything and package">
+        <mkdir dir="${dir.dist}"/>
 
-		<!-- prepare build.xml -->
-		<copy file="${basedir}/build.xml" todir="${dir.dist}"/>
-		<replace file="${dir.dist}/build.xml">
-			<replacetoken><![CDATA[../${name}-${version}]]></replacetoken>
-			<replacevalue><![CDATA[../${name}]]></replacevalue>
-		</replace>
-		<replace file="${dir.dist}/build.xml">
-			<replacetoken><![CDATA[name="dir.jdbc" value="jdbc"]]></replacetoken>
-			<replacevalue><![CDATA[name="dir.jdbc" value="lib"]]></replacevalue>
-		</replace>
+        <!-- prepare build.xml -->
+        <copy file="${basedir}/build.xml" todir="${dir.dist}"/>
+        <replace file="${dir.dist}/build.xml">
+            <replacetoken><![CDATA[../${name}-${version}]]></replacetoken>
+            <replacevalue><![CDATA[../${name}]]></replacevalue>
+        </replace>
+        <replace file="${dir.dist}/build.xml">
+            <replacetoken><![CDATA[name="dir.jdbc" value="jdbc"]]></replacetoken>
+            <replacevalue><![CDATA[name="dir.jdbc" value="lib"]]></replacevalue>
+        </replace>
 
-		<zip zipfile="${dir.dist}/${fullname}.zip">
-			<zipfileset prefix="${name}-${version.major_minor}" file="${dir.build}/${jar.name}.jar" />
-			<zipfileset prefix="${name}-${version.major_minor}/lib"  dir="${dir.build}/versioncheck-dist"/>
-			<zipfileset prefix="${name}-${version.major_minor}/eg" dir="${dir.eg}"/>
-			<zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/build.bat" />
-			<zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/build.sh" />
-			<zipfileset prefix="${name}-${version.major_minor}" file="${dir.dist}/build.xml" />
-			<zipfileset prefix="${name}-${version.major_minor}/etc" dir="${dir.etc}">
-				<exclude name="ehcache.xml" />
-				<exclude name="oscache.properties" />
-			</zipfileset>
-			<zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/lgpl.txt" />
-			<zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/JBossORG-EULA.txt" />
-			<zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/readme.txt" />
-			<zipfileset prefix="${name}-${version.major_minor}" file="${dir.build}/${testjar.name}.jar" />
-			<zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/hibernate_logo.gif" />
-		</zip>
-		<checksum file="${dir.dist}/${fullname}.zip" algorithm="MD5" fileext=".md5.txt"/>
+        <zip zipfile="${dir.dist}/${fullname}.zip">
+            <zipfileset prefix="${name}-${version.major_minor}" file="${dir.build}/${jar.name}.jar"/>
+            <zipfileset prefix="${name}-${version.major_minor}/eg" dir="${dir.eg}"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/build.bat"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/build.sh"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${dir.dist}/build.xml"/>
+            <zipfileset prefix="${name}-${version.major_minor}/etc" dir="${dir.etc}">
+                <exclude name="ehcache.xml"/>
+                <exclude name="oscache.properties"/>
+            </zipfileset>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/lgpl.txt"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/JBossORG-EULA.txt"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/readme.txt"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${dir.build}/${testjar.name}.jar"/>
+            <zipfileset prefix="${name}-${version.major_minor}" file="${basedir}/hibernate_logo.gif"/>
+        </zip>
+        <checksum file="${dir.dist}/${fullname}.zip" algorithm="MD5" fileext=".md5.txt"/>
 
-		<zip zipfile="${dir.dist}/${fullname}-src.zip">
-			<zipfileset prefix="${name}-${version.major_minor}-src/src" dir="${dir.src}"/>
-			<zipfileset prefix="${name}-${version.major_minor}-src/grammar" dir="${dir.grammar}"/>
-			<zipfileset prefix="${name}-${version.major_minor}-src/grammar/gensrc" dir="${dir.out.generated-source}"/>
-			<zipfileset prefix="${name}-${version.major_minor}-src/test" dir="${dir.test}"/>
-			<zipfileset prefix="${name}-${version.major_minor}-src/lib"  dir="${dir.build}/versioncheck-dist"/>
-			<zipfileset prefix="${name}-${version.major_minor}-src/eg" dir="${dir.eg}"/>
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/build.bat" />
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/build.sh" />
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${dir.dist}/build.xml" />
-			<zipfileset prefix="${name}-${version.major_minor}-src/etc" dir="${dir.etc}">
-				<exclude name="ehcache.xml" />
-				<exclude name="oscache.properties" />
-			</zipfileset>
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/hibernate_logo.gif" />
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/lgpl.txt" />
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/JBossORG-EULA.txt" />
-			<zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/readme.txt" />
-        	</zip>
-        	<checksum file="${dir.dist}/${fullname}-src.zip" algorithm="MD5" fileext=".md5.txt"/>
+        <zip zipfile="${dir.dist}/${fullname}-src.zip">
+            <zipfileset prefix="${name}-${version.major_minor}-src/src" dir="${dir.src}"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src/grammar" dir="${dir.grammar}"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src/grammar/gensrc" dir="${dir.out.generated-source}"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src/test" dir="${dir.test}"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src/eg" dir="${dir.eg}"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/build.bat"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/build.sh"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${dir.dist}/build.xml"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src/etc" dir="${dir.etc}">
+                <exclude name="ehcache.xml"/>
+                <exclude name="oscache.properties"/>
+            </zipfileset>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/hibernate_logo.gif"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/lgpl.txt"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/JBossORG-EULA.txt"/>
+            <zipfileset prefix="${name}-${version.major_minor}-src" file="${basedir}/readme.txt"/>
+        </zip>
+        <checksum file="${dir.dist}/${fullname}-src.zip" algorithm="MD5" fileext=".md5.txt"/>
 
-        	<delete file="${dir.dist}/build.xml"/>
-    	</target>
+        <delete file="${dir.dist}/build.xml"/>
+    </target>
 
-    <target name="dist.complete" depends="init,versioncheck,jar,javadoc,antlr.bnf"
+    <target name="dist.complete" depends="init,jar,javadoc,antlr.bnf"
             description="Build and package everything, and run test suite and eg example">
-
         <!-- perform a call to the junit target -->
-        <antcall target="junitreport" />
-
-        <!-- perform a call to the eg.inline target -->
-        <antcall target="eg.inline" />
-
-        <antcall target="dist" />
+        <antcall target="junitreport"/>
+        <antcall target="dist"/>
     </target>
 
 
     <!-- Documentation related targets -->
 
     <target name="javadoc" description="Compile the Javadoc API documentation to dist dir" depends="splash,antlr">
-		<mkdir dir="${dir.out.doc}/api"/>
-		<javadoc classpathref="path.lib"
-                destdir="${dir.out.doc}/api"
-                use="true"
-                protected="true"
-                version="true"
-                doctitle="${Name} API Documentation (${version.full})"
-                windowtitle="${Name} API Documentation"
-                Overview="${dir.doc.api}/package.html"
-                stylesheetfile="${dir.doc.api}/jdstyle.css"
-                source="${javac.source}"
-                link="${javadoc.url.jse}">
-			<packageset dir="${dir.out.generated-source}" defaultexcludes="yes">
-				<include name="org/hibernate/**" />
-			</packageset>
-			<packageset dir="${dir.src}" defaultexcludes="yes">
-				<include name="org/hibernate/**" />
-			</packageset>
-			<group title="Core API"
-				packages="org.hibernate:org.hibernate.classic:org.hibernate.criterion:org.hibernate.metadata:org.hibernate.cfg:org.hibernate.usertype"/>
-			<group title="Extension API"
-				packages="org.hibernate.id:org.hibernate.connection:org.hibernate.transaction:org.hibernate.type:org.hibernate.dialect*:org.hibernate.cache*:org.hibernate.event*:org.hibernate.action:org.hibernate.property:org.hibernate.loader*:org.hibernate.persister*:org.hibernate.proxy:org.hibernate.tuple:org.hibernate.transform:org.hibernate.collection:org.hibernate.jdbc"/>
-			<group title="Miscellaneous API"
-				packages="org.hibernate.stat:org.hibernate.tool.hbm2ddl:org.hibernate.jmx:org.hibernate.mapping:org.hibernate.tool.instrument"/>
-			<group title="Internal Implementation"
-				packages="org.hibernate.engine:org.hibernate.impl:org.hibernate.sql:org.hibernate.lob:org.hibernate.util:org.hibernate.exception:org.hibernate.hql:org.hibernate.hql.ast:org.hibernate.hql.antlr:org.hibernate.hql.classic:org.hibernate.intercept:org.hibernate.secure:org.hibernate.pretty"/>
-		</javadoc>
-		<copy file="${dir.doc.api}/package.html" todir="${dir.out.doc}/api"/>
-	</target>
+        <mkdir dir="${dir.out.doc}/api"/>
+        <javadoc classpathref="path.lib"
+                 destdir="${dir.out.doc}/api"
+                 use="true"
+                 protected="true"
+                 version="true"
+                 doctitle="${Name} API Documentation (${version.full})"
+                 windowtitle="${Name} API Documentation"
+                 Overview="${dir.doc.api}/package.html"
+                 stylesheetfile="${dir.doc.api}/jdstyle.css"
+                 source="${javac.source}"
+                 link="${javadoc.url.jse}">
+            <packageset dir="${dir.out.generated-source}" defaultexcludes="yes">
+                <include name="org/hibernate/**"/>
+            </packageset>
+            <packageset dir="${dir.src}" defaultexcludes="yes">
+                <include name="org/hibernate/**"/>
+            </packageset>
+            <group title="Core API"
+                   packages="org.hibernate:org.hibernate.classic:org.hibernate.criterion:org.hibernate.metadata:org.hibernate.cfg:org.hibernate.usertype"/>
+            <group title="Extension API"
+                   packages="org.hibernate.id:org.hibernate.connection:org.hibernate.transaction:org.hibernate.type:org.hibernate.dialect*:org.hibernate.cache*:org.hibernate.event*:org.hibernate.action:org.hibernate.property:org.hibernate.loader*:org.hibernate.persister*:org.hibernate.proxy:org.hibernate.tuple:org.hibernate.transform:org.hibernate.collection:org.hibernate.jdbc"/>
+            <group title="Miscellaneous API"
+                   packages="org.hibernate.stat:org.hibernate.tool.hbm2ddl:org.hibernate.jmx:org.hibernate.mapping:org.hibernate.tool.instrument"/>
+            <group title="Internal Implementation"
+                   packages="org.hibernate.engine:org.hibernate.impl:org.hibernate.sql:org.hibernate.lob:org.hibernate.util:org.hibernate.exception:org.hibernate.hql:org.hibernate.hql.ast:org.hibernate.hql.antlr:org.hibernate.hql.classic:org.hibernate.intercept:org.hibernate.secure:org.hibernate.pretty"/>
+        </javadoc>
+        <copy file="${dir.doc.api}/package.html" todir="${dir.out.doc}/api"/>
+    </target>
 
-    <!-- miscellaneous targets -->
 
-	<target name="checkstyle" description="Check coding style">
-        <taskdef resource="checkstyletask.properties">
-            <classpath refid="path.lib"/>
-        </taskdef>
-		<checkstyle config="checkstyle_checks.xml">
-			<fileset dir="${dir.src}">
-				<include name="**/*.java"/>
-			</fileset>
-			<formatter type="plain"/>
-		</checkstyle>
-	</target>
-
-
     <target name="prepare-dir-up" depends="jar">
         <!-- for backwards compatibility with where the tools expect to find the jar and libs -->
-    	<property name="targetdir" value="../${name}-${version.major_minor}"/>
-        <mkdir dir="${targetdir}" />
-        <mkdir dir="${targetdir}/lib" />
+        <property name="targetdir" value="../${name}-${version.major_minor}"/>
+        <mkdir dir="${targetdir}"/>
+        <mkdir dir="${targetdir}/lib"/>
 
-        <copy todir="${targetdir}" file="${dir.build}/${jar.name}.jar" />
+        <copy todir="${targetdir}" file="${dir.build}/${jar.name}.jar"/>
         <copy todir="${targetdir}/lib">
-            <fileset dir="${dir.lib}" />
+            <fileset dir="${dir.lib}"/>
         </copy>
 
-    	<copy todir="${targetdir}/doc/api" file="${dir.doc.api}/jdstyle.css"/>
+        <copy todir="${targetdir}/doc/api" file="${dir.doc.api}/jdstyle.css"/>
     </target>
 
 </project>

Deleted: core/branches/Branch_3_2_4_SP1_CP/checkstyle_checks.xml
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/checkstyle_checks.xml	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/checkstyle_checks.xml	2011-10-14 19:04:25 UTC (rev 20979)
@@ -1,115 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.1//EN" "http://www.puppycrawl.com/dtds/configuration_1_1.dtd">
-<module name="Checker">
-    <module name="TreeWalker">
-        <module name="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck">
-            <property name="format" value="^[A-Z](_?[A-Z0-9]+)*$|log"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.GenericIllegalRegexpCheck">
-            <property name="format" value="\(\(|\)\)"/>
-            <property name="ignoreCase" value="false"/>
-            <property name="message" value="stacked parentheses"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck">
-            <property name="severity" value="warning"/>
-            <property name="tokens" value="VARIABLE_DEF"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.design.HideUtilityClassConstructorCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.IllegalInstantiationCheck">
-            <property name="classes" value="{}"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck">
-            <property name="severity" value="warning"/>
-            <property name="tokens" value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN, BSR_ASSIGN, BXOR_ASSIGN, DIV_ASSIGN, MINUS_ASSIGN, MOD_ASSIGN, PLUS_ASSIGN, SL_ASSIGN, SR_ASSIGN, STAR_ASSIGN"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck">
-            <property name="allowMarkerInterfaces" value="true"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck">
-            <property name="maxLineLength" value="80"/>
-            <property name="option" value="eol"/>
-            <property name="severity" value="warning"/>
-            <property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, METHOD_DEF"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.LocalFinalVariableNameCheck">
-            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.LocalVariableNameCheck">
-            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck">
-            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck">
-            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.ModifierOrderCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck">
-            <property name="severity" value="warning"/>
-            <property name="tokens" value="LITERAL_DO, LITERAL_ELSE"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck">
-            <property name="format" value="^[a-z]+(\.[a-zA-Z_][a-zA-Z0-9_]*)*$"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck">
-            <property name="option" value="alone"/>
-            <property name="severity" value="warning"/>
-            <property name="tokens" value="LITERAL_CATCH, LITERAL_ELSE, LITERAL_TRY"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.StaticVariableNameCheck">
-            <property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck">
-            <property name="format" value="^[A-Z][a-zA-Z0-9]*$"/>
-            <property name="severity" value="warning"/>
-            <property name="tokens" value="CLASS_DEF, INTERFACE_DEF"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
-            <property name="severity" value="warning"/>
-        </module>
-        <module name="com.puppycrawl.tools.checkstyle.checks.design.VisibilityModifierCheck">
-            <property name="packageAllowed" value="true"/>
-            <property name="protectedAllowed" value="true"/>
-            <property name="publicMemberPattern" value="^serialVersionUID"/>
-            <property name="severity" value="warning"/>
-        </module>
-    </module>
-</module>

Modified: core/branches/Branch_3_2_4_SP1_CP/grammar/hql-sql.g
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/grammar/hql-sql.g	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/grammar/hql-sql.g	2011-10-14 19:04:25 UTC (rev 20979)
@@ -50,6 +50,8 @@
 	METHOD_NAME;    // An IDENT that is a method name.
 	NAMED_PARAM;    // A named parameter (:foo).
 	BOGUS;          // Used for error state detection, etc.
+	RESULT_VARIABLE_REF;   // An IDENT that refers to result variable
+	                       // (i.e, an alias for a select expression)
 }
 
 // -- Declarations --
@@ -210,7 +212,13 @@
 	protected void lookupAlias(AST ident) throws SemanticException { }
 
     protected void setAlias(AST selectExpr, AST ident) { }
+    protected boolean isOrderExpressionResultVariableRef(AST ident) throws SemanticException {
+        return false;
+    }
+    protected void handleResultVariableRef(AST resultVariableRef) throws SemanticException {
 
+    }
+
 	protected AST lookupProperty(AST dot,boolean root,boolean inSelect) throws SemanticException {
 		return dot;
 	}
@@ -328,9 +336,22 @@
 	;
 
 orderExprs
-	: expr ( ASCENDING | DESCENDING )? (orderExprs)?
+	: orderExpr ( ASCENDING | DESCENDING )? (orderExprs)?
 	;
 
+orderExpr
+    : { isOrderExpressionResultVariableRef( _t ) }? resultVariableRef
+    | expr
+    ;
+
+resultVariableRef!
+    : i:identifier {
+        // Create a RESULT_VARIABLE_REF node instead of an IDENT node.
+        #resultVariableRef = #([RESULT_VARIABLE_REF, i.getText()]);
+        handleResultVariableRef(#resultVariableRef);
+    }
+    ;
+
 groupClause
 	: #(GROUP { handleClauseStart( GROUP ); } (expr)+ ( #(HAVING logicalExpr) )? )
 	;

Modified: core/branches/Branch_3_2_4_SP1_CP/grammar/sql-gen.g
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/grammar/sql-gen.g	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/grammar/sql-gen.g	2011-10-14 19:04:25 UTC (rev 20979)
@@ -419,6 +419,7 @@
 	: #(r:DOT . .) { out(r); }
 	| i:ALIAS_REF { out(i); }
 	| j:INDEX_OP { out(j); }
+	| v:RESULT_VARIABLE_REF { out(v); }
 	;
 
 sqlToken

Deleted: core/branches/Branch_3_2_4_SP1_CP/indent.py
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/indent.py	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/indent.py	2011-10-14 19:04:25 UTC (rev 20979)
@@ -1,45 +0,0 @@
-import re
-import sys
-sys.argv.pop(0)
-for fname in sys.argv:
-	file = open(fname)
-	inlines = file.read().split('\n')
-	file.close()
-	out= []
-	tabcount = 0
-	extratab=0
-	for ln in inlines:
-		code = ln.lstrip('\t ').rstrip('\t ')
-		clen = len(code)
-		javadoc = clen > 0 and code[0]=='*'
-		if javadoc:
-			code = ' ' + code
-		else:
-			begincb = clen > 0 and ( code[0]=='}' or code[0]==')' )
-			tabcount -= begincb
-		
-		extratab = extratab or ( len(code)>0 and code[0]=='.' )
-		
-		tabs = '\t' * (tabcount + extratab)
-		
-		extratab = clen>0 and ( code[clen-1]==':' or code[clen-1]=='?' )
-		
-		if clen>5 and code[0:6] == '} else':
-			code = '}\n' + tabs + 'else' + code[6:]
-		if clen>6 and code[0:7] == '} catch':
-			code = '}\n' + tabs + 'catch' + code[7:]
-		
-		out.append( tabs + code + '\n' )
-		
-		if not javadoc:
-			uncommented = code.split('//')[0].rstrip()
-			clen = len(uncommented)
-			endob = clen > 0 and ( code[clen-1]=='{' or code[clen-1]=='(' )
-			tabcount += endob
-		
-	file = open( fname, 'w' )
-	for ln in out:
-		file.write(ln)
-	file.close()
-
-

Deleted: core/branches/Branch_3_2_4_SP1_CP/readme.txt
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/readme.txt	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/readme.txt	2011-10-14 19:04:25 UTC (rev 20979)
@@ -1,95 +0,0 @@
-Hibernate - Relational Persistence for Idiomatic Java
-=====================================================
-version 3.2.4.sp1.cp11
-Copyright © 2009 Red Hat, Inc.
-
-
-Instructions
-------------
-Unzip to installation directory.
-
-See index.html in the doc/reference directory.
-
-Required jars are distributed in the lib subdirectory.
-
-Install Apache Ant 1.7.0 (http://ant.apache.org/) and set ANT_HOME
-environment variable.
-
-Install JUnit 3.8.1 (http://www.junit.org/) and copy junit.jar to 
-$ANT_HOME/lib. 
-
-
-Get Up And Running Quick
-------------------------
-Demo:
-
-   (1) copy your JDBC driver to the lib directory
-   (2) edit etc/hibernate.properties
-   (3) run "ant eg" or "build eg" using JDK 1.5
-   (4) browse the sourcecode in eg/org/hibernate/auction
-
-Tests:
-
-   (1) copy your JDBC driver to the lib directory
-   (2) edit etc/hibernate.properties
-   (3) run "ant junitreport-dist" or "build junitreport-dist" using JDK 1.5;
-       to ignore "FailureExpected" failures (see note below), run
-       "ant junitreport-dist -Dhibernate.test.validatefailureexpected=true"
-   (4) see build/test-reports/index.html
-
-Note: The unit tests are expected to have 8 failures and 10 errors in:
-
-Ehcache tests (Ehcache is not provided in this distribution):
-org.hibernate.test.cache.ehcache.EhCacheTest.testQueryCacheInvalidation
-org.hibernate.test.cache.ehcache.EhCacheTest.testEmptySecondLevelCacheEntry
-org.hibernate.test.cache.ehcache.EhCacheTest.testStaleWritesLeaveCacheConsistent
-
-"FailureExpected" tests (known issues to be addressed in the future):
-org.hibernate.test.component.basic.ComponentTest.testComponentQueryMethodNoParensFailureExpected
-org.hibernate.test.event.collection.BrokenCollectionEventTest.testUpdateDetachedParentNoChildrenToNullFailureExpected
-org.hibernate.test.event.collection.BrokenCollectionEventTest.testSaveParentNullChildrenFailureExpected
-org.hibernate.test.event.collection.BrokenCollectionEventTest.testUpdateParentNoChildrenToNullFailureExpected
-org.hibernate.test.hql.ASTParserLoadingTest.testParameterTypeMismatchFailureExpected
-org.hibernate.test.hql.CriteriaHQLAlignmentTest.testCriteriaAggregationReturnTypeFailureExpected
-org.hibernate.test.hql.HQLTest.testEmptyInListFailureExpected   
-org.hibernate.test.hql.HQLTest.testMaxindexHqlFuncttestMultipleElementAccessorOperatorsFailureExpectedionInElementAccessorFailureExpected
-org.hibernate.test.hql.HQLTest.testMultipleElementAccessorOperatorsFailureExpected
-org.hibernate.test.hql.HQLTest.testKeyManyToOneJoinFailureExpected
-org.hibernate.test.hql.HQLTest.testDuplicateExplicitJoinFailureExpected
-org.hibernate.test.keymanytoone.bidir.component.EagerKeyManyToOneTest.testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelfFailureExpected
-org.hibernate.test.legacy.SQLLoaderTest.testReturnPropertyComponentRenameFailureExpected
-org.hibernate.test.readonly.ReadOnlyTest.testReadOnlyOnProxiesFailureExpected
-org.hibernate.test.sql.hand.query.NativeSQLQueriesTest.testCompositeIdJoinsFailureExpected 
-
-
-Product Support and License Website Links
------------------------------------------
-Support Processes
-http://www.redhat.com/support/process/
-
-Production Support Scope of Coverage
-http://www.redhat.com/support/policy/soc/production
-
-Production Support Service Level Agreement
-http://www.redhat.com/support/policy/sla/production/
-
-Developer Support Scope of Coverage
-http://www.redhat.com/support/policy/soc/developer/
-
-Developer Support Service Level Agreement
-http://www.redhat.com/support/policy/sla/developer/
-
-Product Update and Support Policy by Product
-http://www.redhat.com/security/updates/jboss_notes/
-
-JBoss End User License Agreement
-http://www.redhat.com/licenses/jboss_eula.html 
-
-Other Stuff
------------
-This software is distributed under the terms of the FSF Lesser Gnu 
-Public License (see lgpl.txt) and the JBoss End User License Agreement 
-(see JBossORG-EULA.txt).
-
-This product includes software developed by the Apache Software 
-Foundation (http://www.apache.org/).

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -1613,6 +1613,20 @@
 		return true;
 	}
 
+    /**
+     * Does this dialect require that references to result variables
+     * (i.e, select expresssion aliases) in an ORDER BY clause be
+     * replaced by column positions (1-origin) as defined
+     * by the select clause?
+     *
+     * @return true if result variable references in the ORDER BY
+     *         clause should be replaced by column positions;
+     *         false otherwise.
+     */
+    public boolean replaceResultVariableInOrderByClauseWithPosition() {
+        return false;
+    }
+
 	/**
 	 * Does this dialect require that parameters appearing in the <tt>SELECT</tt> clause be wrapped in <tt>cast()</tt>
 	 * calls to tell the db parser the expected type.

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -10,13 +10,12 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Arrays;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hibernate.QueryException;
 import org.hibernate.HibernateException;
-import org.hibernate.AssertionFailure;
+import org.hibernate.hql.ast.tree.ResultVariableRefNode;
 import org.hibernate.engine.JoinSequence;
 import org.hibernate.engine.ParameterBinder;
 import org.hibernate.engine.SessionFactoryImplementor;
@@ -105,7 +104,13 @@
 
 	private FromClause currentFromClause = null;
 	private SelectClause selectClause;
+    /**
+     * Maps each top-level result variable to its SelectExpression;
+     * (excludes result variables defined in subqueries)
+     **/
+    private Map<String, SelectExpression> selectExpressionsByResultVariable = new HashMap();
 
+
 	private Set querySpaces = new HashSet();
 
 	private int parameterCount;
@@ -907,8 +912,34 @@
 
     protected void setAlias(AST selectExpr, AST ident) {
         ((SelectExpression) selectExpr).setAlias(ident.getText());
+        // only put the alias (i.e., result variable) in selectExpressionsByResultVariable
+        // if is not defined in a subquery.
+        if ( !isSubQuery() ) {
+            selectExpressionsByResultVariable.put( ident.getText(), (SelectExpression) selectExpr );
+        }
     }
 
+    protected boolean isOrderExpressionResultVariableRef(AST orderExpressionNode) throws SemanticException {
+        // ORDER BY is not supported in a subquery
+        // TODO: should an exception be thrown if an ORDER BY is in a subquery?
+        if ( !isSubQuery() &&
+                orderExpressionNode.getType() == IDENT &&
+                selectExpressionsByResultVariable.containsKey( orderExpressionNode.getText() ) ) {
+            return true;
+        }
+        return false;
+    }
+
+    protected void handleResultVariableRef(AST resultVariableRef) throws SemanticException {
+        if ( isSubQuery() ) {
+            throw new SemanticException(
+                    "References to result variables in subqueries are not supported."
+            );
+        }
+        ( (ResultVariableRefNode) resultVariableRef ).setSelectExpression(
+                selectExpressionsByResultVariable.get( resultVariableRef.getText() )
+        );
+    }
 	/**
 	 * Returns the locations of all occurrences of the named parameter.
 	 */

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -18,6 +18,7 @@
 import org.hibernate.hql.ast.tree.DotNode;
 import org.hibernate.hql.ast.tree.FromClause;
 import org.hibernate.hql.ast.tree.FromElement;
+import org.hibernate.hql.ast.tree.ResultVariableRefNode;
 import org.hibernate.hql.ast.tree.IdentNode;
 import org.hibernate.hql.ast.tree.ImpliedFromElement;
 import org.hibernate.hql.ast.tree.InLogicOperatorNode;
@@ -99,6 +100,8 @@
 			case ALIAS_REF:
 			case IDENT:
 				return IdentNode.class;
+            case RESULT_VARIABLE_REF:
+                 return ResultVariableRefNode.class;
 			case SQL_TOKEN:
 				return SqlFragment.class;
 			case METHOD_CALL:

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractSelectExpression.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractSelectExpression.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractSelectExpression.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -13,6 +13,7 @@
 public abstract class AbstractSelectExpression extends HqlSqlWalkerNode implements SelectExpression {
 	
 	private String alias;
+     private int scalarColumnIndex = -1;
 	
 	public final void setAlias(String alias) {
 		this.alias = alias;
@@ -40,4 +41,12 @@
 		Type type = getDataType();
 		return type != null && !type.isAssociationType();	// Moved here from SelectClause [jsd]
 	}
+    public void setScalarColumn(int i) throws SemanticException {
+        this.scalarColumnIndex = i;
+        setScalarColumnText( i );
+    }
+
+    public int getScalarColumnIndex(){
+        return scalarColumnIndex;
+    }
 }

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ConstructorNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ConstructorNode.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ConstructorNode.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -53,7 +53,20 @@
 		}
 	}
 
-	protected AST getFirstSelectExpression() {
+    public int getScalarColumnIndex() {
+        return -1;
+    }
+
+	public void setScalarColumn(int i) throws SemanticException {
+		SelectExpression[] selectExpressions = collectSelectExpressions();
+		// Invoke setScalarColumnText on each constructor argument.
+		for ( int j = 0; j < selectExpressions.length; j++ ) {
+			SelectExpression selectExpression = selectExpressions[j];
+			selectExpression.setScalarColumn( j );
+		}
+	}
+
+    protected AST getFirstSelectExpression() {
 		// Collect the select expressions, skip the first child because it is the class name.
 		return getFirstChild().getNextSibling();
 	}

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/QueryNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/QueryNode.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/QueryNode.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -23,6 +23,7 @@
 	private static final Log log = LogFactory.getLog( QueryNode.class );
 
 	private OrderByClause orderByClause;
+    private int scalarColumnIndex = -1;
 
 	/**
 	 * @see Statement#getStatementType() 
@@ -122,6 +123,15 @@
 		this.alias = alias;
 	}
 
+    public void setScalarColumn(int i) throws SemanticException {
+        scalarColumnIndex = i;
+        setScalarColumnText( i );
+    }
+
+    public int getScalarColumnIndex() {
+        return scalarColumnIndex;
+    }
+
 	public void setScalarColumnText(int i) throws SemanticException {
 		ColumnHelper.generateSingleScalarColumn( this, i );
 	}

Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ResultVariableRefNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ResultVariableRefNode.java	                        (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/ResultVariableRefNode.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -0,0 +1,93 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ */
+package org.hibernate.hql.ast.tree;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.util.StringHelper;
+import antlr.SemanticException;
+
+/**
+ * Represents a reference to a result_variable as defined in the JPA 2 spec.
+ * For example:
+ * <code>
+ * select v as value from tab1 order by value
+ * </code>
+ * <p/>
+ * "value" used in the order by clause is a reference to the
+ * result_variable, "value", defined in the select clause.
+ *
+ * @author Gail Badner
+ */
+public class ResultVariableRefNode extends HqlSqlWalkerNode {
+	private SelectExpression selectExpression;
+
+	/**
+	 * Set the select expression that defines the result variable.
+	 *
+	 * @param selectExpression the select expression;
+	 *        selectExpression.getAlias() must be non-null
+	 * @throws SemanticException if selectExpression or
+	 *         selectExpression.getAlias() is null.
+	 */
+	public void setSelectExpression(SelectExpression selectExpression) throws SemanticException {
+		if ( selectExpression == null || selectExpression.getAlias() == null ) {
+			throw new SemanticException( "A ResultVariableRefNode must refer to a non-null alias." );
+		}
+		this.selectExpression = selectExpression;
+	}
+
+	/**
+	 *  {@inheritDoc}
+	 */
+	@Override
+    public String getRenderText(SessionFactoryImplementor sessionFactory) {
+		int scalarColumnIndex = selectExpression.getScalarColumnIndex();
+		if ( scalarColumnIndex < 0 ) {
+			throw new IllegalStateException(
+					"selectExpression.getScalarColumnIndex() must be >= 0; actual = " + scalarColumnIndex
+			);
+		}
+		return sessionFactory.getDialect().replaceResultVariableInOrderByClauseWithPosition() ?
+			getColumnPositionsString( scalarColumnIndex ) :
+			getColumnNamesString( scalarColumnIndex );
+
+	}
+
+	private String getColumnPositionsString(int scalarColumnIndex ) {
+		int startPosition = getWalker().getSelectClause().getColumnNamesStartPosition( scalarColumnIndex );
+		StringBuffer buf = new StringBuffer();
+		int nColumns = getWalker().getSelectClause().getColumnNames()[ scalarColumnIndex ].length;
+		for ( int i = startPosition; i < startPosition + nColumns; i++ ) {
+			if ( i > startPosition ) {
+				buf.append( ", " );
+			}
+			buf.append( i );
+		}
+		return buf.toString();
+	}
+
+	private String getColumnNamesString(int scalarColumnIndex) {
+		return StringHelper.join( ", ", getWalker().getSelectClause().getColumnNames()[scalarColumnIndex] );
+	}
+}

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectClause.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectClause.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectClause.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -34,6 +34,7 @@
 	private ConstructorNode constructorNode;
 	private List collectionFromElements;
 	private String[] aliases;
+    private int[] columnNamesStartPositions;
 
 	/**
 	 * Does this SelectClause represent a scalar query
@@ -245,7 +246,16 @@
 
 		// todo: we should really just collect these from the various SelectExpressions, rather than regenerating here
 		columnNames = getSessionFactoryHelper().generateColumnNames( queryReturnTypes );
+        columnNamesStartPositions = new int[ columnNames.length ];
+        int startPosition = 1;
+        for ( int i = 0; i < columnNames.length; i++ ) {
+            columnNamesStartPositions[i] = startPosition;
+            startPosition += columnNames[i].length;
+        }
 	}
+    public int getColumnNamesStartPosition(int i) {
+        return columnNamesStartPositions[ i ];
+    }
 
 	/**
 	 * Prepares a derived (i.e., not explicitly defined in the query) select clause.
@@ -351,7 +361,7 @@
 		if ( !currentFromClause.isSubQuery() ) {
 			for ( int i = 0; i < se.length; i++ ) {
 				SelectExpression expr = se[i];
-				expr.setScalarColumnText( i );	// Create SQL_TOKEN nodes for the columns.
+				expr.setScalarColumn( i );	// Create SQL_TOKEN nodes for the columns.
 			}
 		}
 	}

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectExpression.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectExpression.java	2011-10-13 15:47:09 UTC (rev 20978)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/SelectExpression.java	2011-10-14 19:04:25 UTC (rev 20979)
@@ -18,6 +18,7 @@
 	 */
 	Type getDataType();
 
+
 	/**
 	 * Appends AST nodes that represent the columns after the current AST node.
 	 * (e.g. 'as col0_O_')
@@ -25,8 +26,22 @@
 	 * @param i The index of the select expression in the projection list.
 	 */
 	void setScalarColumnText(int i) throws SemanticException;
+    	/**
+	 * Sets the index and text for select expression in the projection list.
+	 *
+	 * @param i The index of the select expression in the projection list.
+	 * @throws SemanticException
+	 */
+	void setScalarColumn(int i) throws SemanticException;
 
 	/**
+	 * Gets index of the select expression in the projection list.
+	 *
+	 * @returns The index of the select expression in the projection list.
+	 */
+	int getScalarColumnIndex();
+
+	/**
 	 * Returns the FROM element that this expression refers to.
 	 *
 	 * @return The FROM element.



More information about the hibernate-commits mailing list