Hibernate SVN: r15923 - validator/trunk/hibernate-validator-legacy.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-10 10:16:11 -0500 (Tue, 10 Feb 2009)
New Revision: 15923
Modified:
validator/trunk/hibernate-validator-legacy/pom.xml
Log:
Attached the documentation build to the site phase
Modified: validator/trunk/hibernate-validator-legacy/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-10 14:03:31 UTC (rev 15922)
+++ validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-10 15:16:11 UTC (rev 15923)
@@ -184,7 +184,7 @@
<executions>
<execution>
<id>make-doc</id>
- <phase>package</phase>
+ <phase>site</phase>
<goals>
<goal>resources</goal>
<goal>generate</goal>
15 years, 3 months
Hibernate SVN: r15922 - in validator/trunk: hibernate-validator and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-10 09:03:31 -0500 (Tue, 10 Feb 2009)
New Revision: 15922
Added:
validator/trunk/hibernate-validator/readme.txt
Modified:
validator/trunk/hibernate-validator-legacy/pom.xml
validator/trunk/hibernate-validator/src/main/assembly/dist.xml
validator/trunk/pom.xml
Log:
added readme.txt
Added: validator/trunk/hibernate-validator/readme.txt
===================================================================
--- validator/trunk/hibernate-validator/readme.txt (rev 0)
+++ validator/trunk/hibernate-validator/readme.txt 2009-02-10 14:03:31 UTC (rev 15922)
@@ -0,0 +1,66 @@
+
+ Hibernate Validator
+
+ What is it?
+ -----------
+
+ This is a reference implementation of JSR 303 - Bean Validation.
+ Bean Validation defines a metadata model and API for JavaBean validation.
+ The default metadata source is annotations, with the ability to override and extend
+ the meta-data through the use of XML validation descriptors.
+
+ History
+ -------
+
+ Prior to version 4.x Hibernate Validators was based on a different source base which
+ is not based JSR 303. This code can be accessed via
+ http://anonsvn.jboss.org/repos/hibernate/validator/trunk/hibernate-valida...
+
+ Documentation
+ -------------
+
+ The documentation available as of the date of this release is included in
+ HTML format in the dist/docs/ directory.
+
+ Release Notes
+ -------------
+
+ The full list of changes can be found at
+ http://opensource.atlassian.com/projects/hibernate/secure/ConfigureReleas....
+
+ System Requirements
+ -------------------
+
+ JDK 1.5 or above.
+
+ Using Hibernate Validator
+ -------------------------
+
+ - Copy dist/hibernate-validator-*.jar together will all jar files from dist/lib into the
+ classpath of your application
+
+ or
+
+ - Add the following to your maven or ivy dependency list:
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>x.y.z</version>
+ </dependency>
+
+ Hibernate Validator can be found in this repository: http://repository.jboss.com/maven2/
+
+ Licensing
+ ---------
+
+ Please see the file called license.txt
+
+ Hibernate Validator URLS
+ ------------------------
+
+ Home Page: http://validator.hibernate.org/
+ Downloads: http://www.hibernate.org/6.html
+ Mailing Lists: http://www.hibernate.org/20.html
+ Source Code: http://anonsvn.jboss.org/repos/hibernate/validator/trunk/
+ Issue Tracking: http://opensource.atlassian.com/projects/hibernate/browse/HV
Modified: validator/trunk/hibernate-validator/src/main/assembly/dist.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/assembly/dist.xml 2009-02-10 13:56:41 UTC (rev 15921)
+++ validator/trunk/hibernate-validator/src/main/assembly/dist.xml 2009-02-10 14:03:31 UTC (rev 15922)
@@ -45,13 +45,11 @@
<fileSet>
<directory>target/site/apidocs</directory>
<outputDirectory>/dist/docs/api</outputDirectory>
- </fileSet>
-<!--
+ </fileSet>
<fileSet>
<directory>target/docbook/publish/en-US</directory>
<outputDirectory>/dist/docs/manual</outputDirectory>
</fileSet>
--->
<fileSet>
<directory>.</directory>
<outputDirectory></outputDirectory>
Modified: validator/trunk/hibernate-validator-legacy/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-10 13:56:41 UTC (rev 15921)
+++ validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-10 14:03:31 UTC (rev 15922)
@@ -22,10 +22,7 @@
<description>Following the DRY (Don't Repeat Yourself) principle, Hibernate Validator let's you express your domain
constraints once (and only once) and ensure their compliance at various level of your system automatically.
</description>
- <scm>
- <url>http://anonhibernate.labs.jboss.com/trunk/HibernateExt/validator</url>
- </scm>
-
+
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2009-02-10 13:56:41 UTC (rev 15921)
+++ validator/trunk/pom.xml 2009-02-10 14:03:31 UTC (rev 15922)
@@ -138,7 +138,7 @@
<issueManagement>
<system>JIRA</system>
- <url>http://opensource.atlassian.com/projects/hibernate/browse/BVAL</url>
+ <url>http://opensource.atlassian.com/projects/hibernate/browse/HV</url>
</issueManagement>
<inceptionYear>2007</inceptionYear>
@@ -211,5 +211,4 @@
</plugin>
</plugins>
</reporting>
-
</project>
15 years, 3 months
Hibernate SVN: r15921 - validator/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-02-10 08:56:41 -0500 (Tue, 10 Feb 2009)
New Revision: 15921
Modified:
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorFactory.java
Log:
BVAL-114 Relax property names in ConstraintValidatorContext
Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-10 11:41:24 UTC (rev 15920)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-02-10 13:56:41 UTC (rev 15921)
@@ -57,7 +57,7 @@
* If this constraint is used as part of a composed constraint, parameter
* values are reflecting the overridden parameters from the main constraint.
*
- * @return Returns a map containing the annotation paramter names as keys
+ * @return a map containing the annotation paramter names as keys
* and the annotation parameter values as value.
*/
Map<String, Object> getParameters();
Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-02-10 11:41:24 UTC (rev 15920)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorContext.java 2009-02-10 13:56:41 UTC (rev 15921)
@@ -25,7 +25,7 @@
* Add a new error message. This error message will be interpolated.
* <p/>
* If isValid returns false, a ConstraintViolation object will be built per error message
- * including the default one unless #disableDefaultErrorMEssage() has been called.
+ * including the default one unless #disableDefaultError() has been called.
* <p/>
* Aside from the error message, ConstraintViolation objects generated from such a call
* contains the same contextual information (root bean, path and so on)
@@ -42,18 +42,12 @@
* This error message will be interpolated.
* <p/>
* If isValid returns false, a ConstraintViolation object will be built
- * per error message including the default one unless #disableDefaultErrorMEssage()
+ * per error message including the default one unless #disableDefaultError()
* has been called.
- * If the constraint being validated is not a class-level constraint,
- * a ValidationException is raised.
- *
* <p/>
*
* @param message new unexpanded error message
* @param property property name the ConstraintViolation is targeting
- *
- * @throws ValidationException if the constraint is not set on a class-level
*/
void addError(String message, String property);
-
}
Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorFactory.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorFactory.java 2009-02-10 11:41:24 UTC (rev 15920)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidatorFactory.java 2009-02-10 13:56:41 UTC (rev 15921)
@@ -31,7 +31,7 @@
/**
* @param key The class of the constraint validator to instantiate.
*
- * @return An constraint validator instance of the specified class.
+ * @return A constraint validator instance of the specified class.
*/
<T extends ConstraintValidator<?,?>> T getInstance(Class<T> key);
}
15 years, 3 months
Hibernate SVN: r15920 - in validator/trunk: hibernate-validator and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-10 06:41:24 -0500 (Tue, 10 Feb 2009)
New Revision: 15920
Added:
validator/trunk/hibernate-validator-legacy/license.txt
validator/trunk/hibernate-validator/license.txt
validator/trunk/hibernate-validator/src/main/assembly/
validator/trunk/hibernate-validator/src/main/assembly/dist.xml
validator/trunk/validation-api/license.txt
Modified:
validator/trunk/hibernate-validator-legacy/pom.xml
validator/trunk/hibernate-validator/pom.xml
validator/trunk/pom.xml
validator/trunk/validation-api/pom.xml
Log:
Prepared pom version for release, updated some site report plugins, made sure the license files are there and added assembly plugin to hibernate-validator
Added: validator/trunk/hibernate-validator/license.txt
===================================================================
--- validator/trunk/hibernate-validator/license.txt (rev 0)
+++ validator/trunk/hibernate-validator/license.txt 2009-02-10 11:41:24 UTC (rev 15920)
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-02-09 19:32:49 UTC (rev 15919)
+++ validator/trunk/hibernate-validator/pom.xml 2009-02-10 11:41:24 UTC (rev 15920)
@@ -5,7 +5,7 @@
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
- <version>4.0.0.Alpha1-SNAPSHOT</version>
+ <version>4.0.0.Alpha1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -15,7 +15,7 @@
<distributionManagement>
<site>
<id>site</id>
- <url>file:///Users/hardy/Sites/${artifactId}</url>
+ <url>http://validator.hibernate.org</url>
</site>
</distributionManagement>
<dependencies>
@@ -54,6 +54,14 @@
</resources>
<plugins>
<plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/dist.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
<version>2.1.0</version>
@@ -164,7 +172,6 @@
<configuration>
<compilerArgument>-proc:only</compilerArgument>
<compilerArguments>
- <s>foo</s>
<processor>org.hibernate.tck.report.CoverageProcessor</processor>
</compilerArguments>
</configuration>
Added: validator/trunk/hibernate-validator/src/main/assembly/dist.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/assembly/dist.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/assembly/dist.xml 2009-02-10 11:41:24 UTC (rev 15920)
@@ -0,0 +1,65 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<assembly>
+ <id>dist</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>tar.bz2</format>
+ <format>zip</format>
+ </formats>
+
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory>/dist/lib</outputDirectory>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+
+ <fileSets>
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>/dist</outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/site/apidocs</directory>
+ <outputDirectory>/dist/docs/api</outputDirectory>
+ </fileSet>
+<!--
+ <fileSet>
+ <directory>target/docbook/publish/en-US</directory>
+ <outputDirectory>/dist/docs/manual</outputDirectory>
+ </fileSet>
+-->
+ <fileSet>
+ <directory>.</directory>
+ <outputDirectory></outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <excludes>
+ <exclude>**/target/**</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
Added: validator/trunk/hibernate-validator-legacy/license.txt
===================================================================
--- validator/trunk/hibernate-validator-legacy/license.txt (rev 0)
+++ validator/trunk/hibernate-validator-legacy/license.txt 2009-02-10 11:41:24 UTC (rev 15920)
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Modified: validator/trunk/hibernate-validator-legacy/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-09 19:32:49 UTC (rev 15919)
+++ validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-10 11:41:24 UTC (rev 15920)
@@ -5,7 +5,7 @@
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
- <version>4.0.0.Alpha1-SNAPSHOT</version>
+ <version>4.0.0.Alpha1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hibernate-validator-legacy</artifactId>
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2009-02-09 19:32:49 UTC (rev 15919)
+++ validator/trunk/pom.xml 2009-02-10 11:41:24 UTC (rev 15920)
@@ -6,9 +6,9 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-parent</artifactId>
<packaging>pom</packaging>
- <version>4.0.0.Alpha1-SNAPSHOT</version>
+ <version>4.0.0.Alpha1</version>
<name>Hibernate Validator Parent</name>
- <url>http://localhost/~hardy/</url>
+ <url>http://validator.hibernate.org</url>
<description>
Hibernate's Bean Validation (JSR-303) reference implementation.
@@ -16,35 +16,28 @@
<developers>
<developer>
+ <id>epbernard</id>
<name>Emmanuel Bernard</name>
<email>emmanuel(a)hibernate.org</email>
<organization>JBoss, a division of Red Hat</organization>
<url>http://in.relation.to/Bloggers/Emmanuel</url>
</developer>
<developer>
+ <id>hardy.ferentschik</id>
<name>Hardy Ferentschik</name>
<email>hferents(a)redhat.com</email>
<organization>JBoss, a division of Red Hat</organization>
<url>http://in.relation.to/Bloggers/Hardy</url>
</developer>
</developers>
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- </pluginRepository>
- </pluginRepositories>
-
+
+ <mailingLists>
+ <mailingList>
+ <name>hibernate-dev</name>
+ <post>hibernate-dev(a)lists.jboss.org</post>
+ </mailingList>
+ </mailingLists>
+
<modules>
<module>validation-api</module>
<module>hibernate-validator</module>
@@ -56,7 +49,7 @@
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>1.0.Beta3-SNAPSHOT</version>
+ <version>1.0.Beta3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -158,7 +151,7 @@
</licenses>
<scm>
- <connection>scm:https://svn.jboss.org/repos/hibernate/validator/trunk</connection>
+ <connection>scm:svn://svn.jboss.org/repos/hibernate/validator/trunk</connection>
<url>http://fisheye.jboss.org/browse/Hibernate/validator/trunk</url>
</scm>
@@ -175,10 +168,6 @@
<name>JBoss Snapshot Repository</name>
<url>dav:https://snapshots.jboss.org/maven2</url>
</snapshotRepository>
- <site>
- <id>site</id>
- <url>file:///Users/hardy/Sites</url>
- </site>
</distributionManagement>
<reporting>
@@ -204,6 +193,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
+ <configuration>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Added: validator/trunk/validation-api/license.txt
===================================================================
--- validator/trunk/validation-api/license.txt (rev 0)
+++ validator/trunk/validation-api/license.txt 2009-02-10 11:41:24 UTC (rev 15920)
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
Modified: validator/trunk/validation-api/pom.xml
===================================================================
--- validator/trunk/validation-api/pom.xml 2009-02-09 19:32:49 UTC (rev 15919)
+++ validator/trunk/validation-api/pom.xml 2009-02-10 11:41:24 UTC (rev 15920)
@@ -6,7 +6,7 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>1.0.Beta3-SNAPSHOT</version>
+ <version>1.0.Beta3</version>
<packaging>jar</packaging>
<name>Bean Validation API</name>
@@ -16,35 +16,21 @@
<developers>
<developer>
+ <id>epbernard</id>
<name>Emmanuel Bernard</name>
<email>emmanuel(a)hibernate.org</email>
<organization>JBoss, a division of Red Hat</organization>
<url>http://in.relation.to/Bloggers/Emmanuel</url>
</developer>
<developer>
+ <id>hardy.ferentschik</id>
<name>Hardy Ferentschik</name>
<email>hferents(a)redhat.com</email>
<organization>JBoss, a division of Red Hat</organization>
<url>http://in.relation.to/Bloggers/Hardy</url>
</developer>
</developers>
-
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- </pluginRepository>
- </pluginRepositories>
-
+
<build>
<extensions>
<extension>
15 years, 3 months
Hibernate SVN: r15919 - in core/branches/SQL_GEN_REDESIGN: src/main/java/org/hibernate/persister and 10 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-02-09 14:32:49 -0500 (Mon, 09 Feb 2009)
New Revision: 15919
Added:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/MappedTableMetadata.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Dot.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexCollectionElementReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexedCollectionElementAccessPersisterReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterJoin.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoin.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoinBuilder.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyPathTerminus.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/StatementStack.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/AbstractPathNormalizationStrategy.java
core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/
core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/ResolverTest.java
Removed:
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/AbstractPathNormalizationStrategy.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorCounter.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorReporter.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ParseErrorHandler.java
Modified:
core/branches/SQL_GEN_REDESIGN/pom.xml
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/Queryable.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/ASTFactoryImpl.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/AbstractPersisterReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/EntityPersisterReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/HqlNormalizer.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Join.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContext.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContextAwareNode.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterAliasReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceBuilder.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceContext.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyReference.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/RootPersisterReferenceContext.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathNormalizationStrategy.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathedPropertyReferenceSource.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/BasicPathNormalizationStrategySupport.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/FromClausePathNormalizationStrategy.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/SelectClausePathNormalizationStrategy.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/WithFragmentPathNormalizationStrategy.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/HqlParser.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/PathCollector.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTPrinter.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTUtil.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorHandlerDelegateImpl.java
core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/PathHelper.java
core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizerTest.java
core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/parse/ParserTest.java
Log:
HHH-2407 : HQL translation rework ->
HHH-3687 : parse (phase1)
HHH-3688 : normalize (phase2)
Modified: core/branches/SQL_GEN_REDESIGN/pom.xml
===================================================================
--- core/branches/SQL_GEN_REDESIGN/pom.xml 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/pom.xml 2009-02-09 19:32:49 UTC (rev 15919)
@@ -197,6 +197,9 @@
<name>hql/normalize.g</name>
</grammar>
<grammar>
+ <name>hql/resolve.g</name>
+ </grammar>
+ <grammar>
<name>order/parse.g</name>
</grammar>
<grammar>
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/MappedTableMetadata.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/MappedTableMetadata.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/MappedTableMetadata.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,108 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.persister;
+
+/**
+ * Provides access to information about the tables used to persist a collection or entity.
+ * <p/>
+ * Note that this includes all inheritence tables and secondary tables. The "main" table is called the
+ * {@link #getDrivingTableName() driving} table. This is the table from which all {@link #getJoinedTables joins}
+ * originate.
+ *
+ * @author Steve Ebersole
+ */
+public interface MappedTableMetadata {
+ /**
+ * Provides information about a secondary or inheritence table to which we must join to define the entire
+ * table space for this thing being persisted.
+ */
+ public static class JoinedTable {
+ private final String name;
+ private final String[] keyColumns;
+ private final boolean useInnerJoin;
+
+ /**
+ * Create a JoinedTable definition. By default we are saying to not use inner joins.
+ *
+ * @param name The table name.
+ * @param keyColumns The columns which make up the key to the {@link MappedTableMetadata#getDrivingTableName driving}
+ * table.
+ */
+ public JoinedTable(String name, String[] keyColumns) {
+ this( name, keyColumns, false );
+ }
+
+ /**
+ * Create a JoinedTable definition.
+ *
+ * @param name The table name.
+ * @param keyColumns The columns which make up the key to the {@link MappedTableMetadata#getDrivingTableName driving}
+ * table.
+ * @param useInnerJoin Should we use an inner join (faster, but restrictive) as the join type?
+ */
+ public JoinedTable(String name, String[] keyColumns, boolean useInnerJoin) {
+ this.name = name;
+ this.keyColumns = keyColumns;
+ this.useInnerJoin = useInnerJoin;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String[] getKeyColumns() {
+ return keyColumns;
+ }
+
+ public boolean useInnerJoin() {
+ return useInnerJoin;
+ }
+ }
+
+
+ public String getSqlAliasRootBase();
+
+ /**
+ * Get the name of the driving table.
+ *
+ * @return
+ */
+ public String getDrivingTableName();
+
+ /**
+ * Get the names of the identifier columns from the driving table. The entity persisters
+ * assume that all <i>key</i> mappings refer to the driving table's PK (this is true for both <i>join</i> and
+ * <i>joined-subclass</i> mappings).
+ *
+ * @return The driving table columns used in all {@link #getJoinedTables joins}
+ */
+ public String[] getIdentifierColumnNames();
+
+ /**
+ * Tables to which we must join to provide the complete "table space" for the given persister.
+ *
+ * @return The joined table definitions.
+ */
+ public JoinedTable[] getJoinedTables();
+}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -36,6 +36,7 @@
import java.util.Map;
import java.util.Set;
import java.util.Comparator;
+import java.util.LinkedHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,6 +49,7 @@
import org.hibernate.QueryException;
import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException;
+import org.hibernate.persister.MappedTableMetadata;
import org.hibernate.jdbc.Expectation;
import org.hibernate.jdbc.Expectations;
import org.hibernate.jdbc.TooManyRowsAffectedException;
@@ -2838,6 +2840,63 @@
return false;
}
+
+ public class MappedTableMetadataImpl implements MappedTableMetadata {
+ private final JoinedTable[] joinedTables;
+
+ public MappedTableMetadataImpl() {
+ LinkedHashMap joinedTableMap = new LinkedHashMap();
+
+ int sublassTableCount = getSubclassTableSpan();
+ for ( int i = 1; i < sublassTableCount; i++ ) {
+ final String tableName = getSubclassTableName( i );
+ JoinedTable joinedTable = ( JoinedTable ) joinedTableMap.get( tableName );
+ if ( joinedTable == null && !getTableName().equals( tableName ) ) {
+ joinedTable = new JoinedTable( tableName, getSubclassTableKeyColumns( i ), isClassOrSuperclassTable( i ) );
+ joinedTableMap.put( tableName, joinedTable );
+ }
+ }
+
+ int tableCount = getTableSpan();
+ for ( int i = 1; i < tableCount; i++ ) {
+ final String tableName = getTableName( i );
+ JoinedTable joinedTable = ( JoinedTable ) joinedTableMap.get( tableName );
+ if ( joinedTable == null && !getTableName().equals( tableName ) ) {
+ joinedTable = new JoinedTable( tableName, getKeyColumns( i ) );
+ joinedTableMap.put( tableName, joinedTable );
+ }
+ }
+
+ this.joinedTables = ( JoinedTable[] ) joinedTableMap.values().toArray( new JoinedTable[ joinedTableMap.size() ] );
+ }
+
+ public String getSqlAliasRootBase() {
+ return StringHelper.unqualifyEntityName( entityMetamodel.getName() ).toLowerCase();
+ }
+
+ public String getDrivingTableName() {
+ return getTableName();
+ }
+
+ public String[] getIdentifierColumnNames() {
+ return AbstractEntityPersister.this.getIdentifierColumnNames();
+ }
+
+ public JoinedTable[] getJoinedTables() {
+ return joinedTables;
+ }
+ }
+
+
+ private MappedTableMetadata mappedTableMetadata;
+
+ public MappedTableMetadata getMappedTableMetadata() {
+ if ( mappedTableMetadata == null) {
+ mappedTableMetadata = new MappedTableMetadataImpl();
+ }
+ return mappedTableMetadata;
+ }
+
protected JoinFragment createJoin(String name, boolean innerJoin, boolean includeSubclasses) {
final String[] idCols = StringHelper.qualify( name, getIdentifierColumnNames() ); //all joins join to the pk of the driving table
final JoinFragment join = getFactory().getDialect().createOuterJoinFragment();
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/Queryable.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/Queryable.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/persister/entity/Queryable.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -24,6 +24,8 @@
*/
package org.hibernate.persister.entity;
+import org.hibernate.persister.MappedTableMetadata;
+
/**
* Extends the generic <tt>EntityPersister</tt> contract to add
* operations required by the Hibernate Query Language
@@ -174,4 +176,11 @@
return name;
}
}
+
+ /**
+ * Get access to the persister's mapped table metadata.
+ *
+ * @return The mapped table metadata
+ */
+ public MappedTableMetadata getMappedTableMetadata();
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/ASTFactoryImpl.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/ASTFactoryImpl.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/ASTFactoryImpl.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -44,16 +44,24 @@
switch ( tokenType ) {
case IDENT :
return Ident.class;
+ case DOT :
+ return Dot.class;
case ENTITY_PERSISTER_REF :
return EntityPersisterReference.class;
case COLLECTION_PERSISTER_REF :
return CollectionPersisterReference.class;
- case JOIN :
- return Join.class;
+ case INDEXED_COLLECTION_ACCESS_PERSISTER_REF :
+ return IndexedCollectionElementAccessPersisterReference.class;
+ case PROPERTY_JOIN :
+ return PropertyJoin.class;
+ case PERSISTER_JOIN :
+ return PersisterJoin.class;
case ALIAS_REF :
return PersisterAliasReference.class;
case PROPERTY_REF :
return PropertyReference.class;
+ case INDEXED_COLLECTION_ELEMENT_REF :
+ return IndexCollectionElementReference.class;
case INSERT :
return InsertStatement.class;
case UPDATE :
@@ -97,7 +105,7 @@
*/
protected void initialize(AST ast) {
if ( ast instanceof NormalizationContextAwareNode ) {
- ( ( NormalizationContextAwareNode ) ast ).injectResolutionContext( resolutionContext );
+ ( ( NormalizationContextAwareNode ) ast ).injectNormalizationContext( resolutionContext );
}
}
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/AbstractPersisterReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/AbstractPersisterReference.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/AbstractPersisterReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -30,11 +30,12 @@
/**
* Base class for {@link PersisterReference} implementations. Mainly it centralizes handling
- * of reusable proerty joins.
+ * of reusable property joins.
*
* @author Steve Ebersole
*/
-public abstract class AbstractPersisterReference extends Node implements PersisterReference {
+public abstract class AbstractPersisterReference extends Node implements PersisterReference, NormalizationContextAwareNode {
+ private NormalizationContext normalizationContext;
private Map reusablePropertyJoins = new HashMap();
/**
@@ -57,4 +58,31 @@
public PersisterReference locatePersisterReference() {
return this;
}
+
+ /**
+ * Getter for property 'aliasNode'.
+ *
+ * @return Value for property 'aliasNode'.
+ */
+ protected Node getAliasNode() {
+ return ( Node ) getFirstChild().getNextSibling();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getAlias() {
+ return getAliasNode().getText();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void injectNormalizationContext(NormalizationContext normalizationContext) {
+ this.normalizationContext = normalizationContext;
+ }
+
+ protected NormalizationContext normalizationContext() {
+ return normalizationContext;
+ }
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/CollectionPersisterReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -38,8 +38,7 @@
*
* @author Steve Ebersole
*/
-public class CollectionPersisterReference extends AbstractPersisterReference implements PersisterReference, NormalizationContextAwareNode, DisplayableNode {
- private NormalizationContext resolutionContext;
+public class CollectionPersisterReference extends AbstractPersisterReference implements DisplayableNode {
private transient QueryableCollection persister;
/**
@@ -113,18 +112,11 @@
return getPropertyType( propertyName ) != null;
}
- /**
- * {@inheritDoc}
- */
- public void injectResolutionContext(NormalizationContext resolutionContext) {
- this.resolutionContext = resolutionContext;
- }
-
private SessionFactoryImplementor getSessionFactory() {
- if ( resolutionContext == null ) {
+ if ( normalizationContext() == null ) {
throw new AssertionFailure( "resolution context was null on attempt to retrieve session factory reference" );
}
- return resolutionContext.getSessionFactoryImplementor();
+ return normalizationContext().getSessionFactoryImplementor();
}
/**
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Dot.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Dot.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Dot.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,37 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import org.hibernate.sql.ast.common.Node;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class Dot extends Node {
+ public String getText() {
+ return getFirstChild().getText() + '.' + getFirstChild().getNextSibling().getText();
+ }
+}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/EntityPersisterReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/EntityPersisterReference.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/EntityPersisterReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -41,9 +41,7 @@
*
* @author Steve Ebersole
*/
-public class EntityPersisterReference extends AbstractPersisterReference
- implements NormalizationContextAwareNode, DisplayableNode {
- private NormalizationContext resolutionContext;
+public class EntityPersisterReference extends AbstractPersisterReference implements DisplayableNode {
private transient Queryable persister;
/**
@@ -111,18 +109,11 @@
return getPropertyType( propertyName ) != null;
}
- /**
- * {@inheritDoc}
- */
- public void injectResolutionContext(NormalizationContext resolutionContext) {
- this.resolutionContext = resolutionContext;
- }
-
private SessionFactoryImplementor getSessionFactory() {
- if ( resolutionContext == null ) {
- throw new AssertionFailure( "resolution context was null on attempt to retrieve session factory reference" );
+ if ( normalizationContext() == null ) {
+ throw new AssertionFailure( "normalizatioon context was null on attempt to retrieve session factory reference" );
}
- return resolutionContext.getSessionFactoryImplementor();
+ return normalizationContext().getSessionFactoryImplementor();
}
/**
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/HqlNormalizer.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/HqlNormalizer.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/HqlNormalizer.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -25,14 +25,18 @@
import java.io.PrintStream;
import java.io.PrintWriter;
+import java.util.List;
+import java.util.Iterator;
+import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.hibernate.sql.ast.util.ParseErrorHandler;
-import org.hibernate.sql.ast.util.ErrorCounter;
+import org.hibernate.sql.ast.util.ErrorHandlerDelegate;
+import org.hibernate.sql.ast.util.ErrorHandlerDelegateImpl;
import org.hibernate.sql.ast.util.ASTPrinter;
import org.hibernate.sql.ast.common.JoinType;
+import org.hibernate.sql.ast.common.Node;
import org.hibernate.sql.ast.phase.hql.normalize.path.impl.FromClausePathNormalizationStrategy;
import org.hibernate.sql.ast.phase.hql.normalize.path.impl.BasicPathNormalizationStrategySupport;
import org.hibernate.sql.ast.phase.hql.normalize.path.impl.SelectClausePathNormalizationStrategy;
@@ -40,8 +44,13 @@
import org.hibernate.sql.ast.phase.hql.normalize.path.impl.WithFragmentPathNormalizationStrategy;
import org.hibernate.QueryException;
import org.hibernate.MappingException;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.type.Type;
import org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategyStack;
import org.hibernate.sql.ast.phase.hql.normalize.path.PathedPropertyReferenceSource;
+import org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy;
+import org.hibernate.sql.ast.DetailedSemanticException;
+import org.hibernate.sql.ast.alias.ImplicitAliasGenerator;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.util.StringHelper;
@@ -60,9 +69,11 @@
private final SessionFactoryImplementor sessionFactory;
private final PersisterReferenceBuilder persisterReferenceBuilder;
- private final ParseErrorHandler parseErrorHandler = new ErrorCounter();
+ private final PropertyJoinBuilder propertyJoinBuilder;
+ private final ErrorHandlerDelegate parseErrorHandler = new ErrorHandlerDelegateImpl();
private final ASTPrinter printer = new ASTPrinter( HqlNormalizeTokenTypes.class );
- private final AliasBuilder aliasBuilder = new AliasBuilder();
+ private final ImplicitAliasGenerator aliasBuilder = new ImplicitAliasGenerator();
+ private final StatementStack statementStack = new StatementStack();
private final PathNormalizationStrategyStack pathNormalizationStrategyStack = new PathNormalizationStrategyStack();
private int traceDepth = 0;
@@ -71,6 +82,7 @@
super();
this.sessionFactory = sessionFactory;
this.persisterReferenceBuilder = new PersisterReferenceBuilder( this );
+ this.propertyJoinBuilder = new PropertyJoinBuilder( this );
super.setASTFactory( new ASTFactoryImpl( this ) );
}
@@ -79,6 +91,37 @@
}
+ // handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public void traceIn(String ruleName, AST tree) {
+ if ( inputState.guessing > 0 ) {
+ return;
+ }
+ String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
+ String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
+ trace( prefix + traceText );
+ }
+
+ private String buildTraceNodeName(AST tree) {
+ return tree == null
+ ? "???"
+ : tree.getText() + " [" + printer.getTokenTypeName( tree.getType() ) + "]";
+ }
+
+ public void traceOut(String ruleName, AST tree) {
+ if ( inputState.guessing > 0 ) {
+ return;
+ }
+ String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
+ trace( prefix + ruleName );
+ }
+
+ private void trace(String msg) {
+ System.out.println( msg );
+// log.trace( msg );
+ }
+
+
// overrides of Antlr infastructure methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void reportError(RecognitionException e) {
@@ -93,7 +136,7 @@
getParseErrorHandler().reportWarning( s );
}
- public ParseErrorHandler getParseErrorHandler() {
+ public ErrorHandlerDelegate getParseErrorHandler() {
return parseErrorHandler;
}
@@ -107,7 +150,7 @@
}
- // Resolution state ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ // Normalization context ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private PersisterReferenceContext currentPersisterReferenceContext;
@@ -115,6 +158,10 @@
return currentPersisterReferenceContext;
}
+ public PathNormalizationStrategy getCurrentPathNormalizationStrategy() {
+ return pathNormalizationStrategyStack.getCurrent();
+ }
+
protected void pushStatement(AST statementNode) {
if ( currentPersisterReferenceContext == null ) {
currentPersisterReferenceContext = new RootPersisterReferenceContext();
@@ -124,9 +171,11 @@
}
pathNormalizationStrategyStack.push( new BasicPathNormalizationStrategySupport( this ) );
+ statementStack.push( ( Statement ) statementNode );
}
protected void popStatement() {
+ statementStack.pop();
pathNormalizationStrategyStack.pop();
if ( currentPersisterReferenceContext instanceof HierarchicalPersisterReferenceContext ) {
currentPersisterReferenceContext = ( ( HierarchicalPersisterReferenceContext ) currentPersisterReferenceContext ).getParent();
@@ -136,10 +185,7 @@
}
}
-
- // ResolutionContext impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public AliasBuilder getAliasBuilder() {
+ public ImplicitAliasGenerator getAliasBuilder() {
return aliasBuilder;
}
@@ -155,64 +201,74 @@
return persisterReferenceBuilder;
}
+ public PropertyJoinBuilder getPropertyJoinBuilder() {
+ return propertyJoinBuilder;
+ }
- // handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public void traceIn(String ruleName, AST tree) {
- if ( inputState.guessing > 0 ) {
- return;
- }
- String prefix = StringHelper.repeat( '-', (traceDepth++ * 2) ) + "-> ";
- String traceText = ruleName + " (" + buildTraceNodeName(tree) + ")";
- trace( prefix + traceText );
+ public void registerAssociationFetch(Join join) {
+ // todo : implement
}
- private String buildTraceNodeName(AST tree) {
- return tree == null
- ? "???"
- : tree.getText() + " [" + printer.getTokenTypeName( tree.getType() ) + "]";
+ public void registerPropertyFetch(PersisterReference persisterReference) {
+ // todo : implement
}
- public void traceOut(String ruleName, AST tree) {
- if ( inputState.guessing > 0 ) {
+
+ // semantic action overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected void applyCollectionFilter(AST querySpecIn) {
+ if ( isSubquery() ) {
return;
}
- String prefix = "<-" + StringHelper.repeat( '-', (--traceDepth * 2) ) + " ";
- trace( prefix + ruleName );
- }
- private void trace(String msg) {
- System.out.println( msg );
-// log.trace( msg );
- }
+ AST potentialFilterRole = querySpecIn.getFirstChild();
+ if ( potentialFilterRole == null || potentialFilterRole.getType() != FILTER ) {
+ return;
+ }
+ final String collectionRole = potentialFilterRole.getText();
+ trace( "applying collection filter for role [" + collectionRole + "]" );
- // AST output methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ // Remove the FILTER node from the tree as we are about to expand it...
+ querySpecIn.setFirstChild( potentialFilterRole.getNextSibling() );
- public void dumpAst(AST ast) {
- dumpAst( ast, "DUMP" );
- }
+ QueryableCollection persister = ( QueryableCollection ) getSessionFactoryImplementor().getCollectionPersister( collectionRole );
- public void dumpAst(AST ast, String header) {
- log.info( printer.showAsString( ast, header ) );
- }
+ if ( !persister.getElementType().isEntityType() ) {
+ throw new QueryException( "cannot filter collection of values" );
+ }
- public void showAst(AST ast, PrintStream out) {
- showAst( ast, new PrintWriter( out ) );
- }
+ String collectionElementEntityName = persister.getElementPersister().getEntityName();
- private void showAst(AST ast, PrintWriter pw) {
- printer.showAst( ast, pw );
- }
+ AST persisterSpace = astFactory.create( PERSISTER_SPACE, "filter-persister-space" );
+ AST persisterRef = astFactory.create( ENTITY_PERSISTER_REF, "filter-persister-ref" );
+ persisterSpace.setFirstChild( persisterRef );
+ persisterRef.addChild( astFactory.create( ENTITY_NAME, collectionElementEntityName ) );
+ persisterRef.addChild( astFactory.create( ALIAS, "this" ) );
+ persisterRef.addChild( astFactory.create( FILTER, collectionRole ) );
+ registerPersisterReference( persisterRef );
- private String textOrNull(AST ast) {
- return ast == null ? null : ast.getText();
+ AST selectFromNode = querySpecIn.getFirstChild();
+ assert selectFromNode.getType() == SELECT_FROM : "mis-structured AST";
+
+ AST fromClauseNode = selectFromNode.getFirstChild();
+ if ( fromClauseNode == null ) {
+ fromClauseNode = astFactory.create( FROM, "from" );
+ selectFromNode.setFirstChild( fromClauseNode );
+ }
+ else if ( fromClauseNode.getType() == SELECT ) {
+ AST tmp = astFactory.create( FROM, "from" );
+ tmp.setFirstChild( fromClauseNode ); // really the SELECT clause
+ fromClauseNode = tmp;
+ selectFromNode.setFirstChild( fromClauseNode );
+ }
+
+ assert fromClauseNode.getType() == FROM : "mis-structured AST";
+ fromClauseNode.addChild( persisterSpace ); // make it the first child???
}
- // function processing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
private boolean processingFunction;
protected void startingFunction() {
@@ -227,10 +283,7 @@
return processingFunction;
}
-
- // persister-related semntic action overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected AST normalizeEntityName(AST node) throws SemanticException {
+ protected AST normalizeEntityName(AST node) throws SemanticException {
String entityName = node.getText();
if ( !isEntityName( entityName ) ) {
final String importedName = getSessionFactoryImplementor().getImportedClassName( entityName );
@@ -265,8 +318,6 @@
}
- // property-related semntic action overrides ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
protected String locateOwningPersisterAlias(AST property) {
PersisterReference persisterReference = getCurrentPersisterReferenceContext()
.locatePersisterReferenceExposingProperty( property.getText() );
@@ -274,8 +325,6 @@
}
- // path normalization ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
protected AST normalizeQualifiedRoot(AST alias) {
log.debug( "normalizing path expression root as alias [" + alias.getText() + "]" );
return pathNormalizationStrategyStack.getCurrent().handleRoot( getCurrentPersisterReferenceContext().locatePersisterReferenceByAlias( alias.getText() ) );
@@ -287,6 +336,10 @@
return root.handleIntermediatePathPart( ( Ident ) propertyName );
}
+ protected AST normalizeUnqualifiedPropertyReferenceSource(AST propertyName) {
+ return pathNormalizationStrategyStack.getCurrent().handleRoot( getCurrentPersisterReferenceContext().locatePersisterReferenceExposingProperty( propertyName.getText() ) );
+ }
+
protected AST normalizePropertyPathIntermediary(AST source, AST propertyNameNode) {
log.trace( "normalizing intermediate path expression [" + textOrNull( propertyNameNode ) + "]" );
return pathNormalizationStrategyStack.getCurrent().handleIntermediatePathPart( ( PathedPropertyReferenceSource ) source, ( Ident ) propertyNameNode );
@@ -297,9 +350,45 @@
return pathNormalizationStrategyStack.getCurrent().handleTerminalPathPart( ( PathedPropertyReferenceSource ) source, ( Ident ) propertyNameNode );
}
+ protected AST normalizeIntermediateIndexOperation(AST collectionPath, AST selector) throws SemanticException {
+ log.trace( "normalizing intermediate index access [" + textOrNull( collectionPath ) + "]" );
+ PathedPropertyReferenceSource collectionSource = ( PathedPropertyReferenceSource ) collectionPath.getFirstChild();
+ Ident collectionProperty = ( Ident ) collectionSource.getNextSibling();
+ return pathNormalizationStrategyStack.getCurrent().handleIntermediateIndexAccess( collectionSource, collectionProperty, ( Node ) selector );
+ }
- // property path normalization strategies ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ protected AST normalizeTerminalIndexOperation(AST collectionPath, AST selector) throws SemanticException {
+ log.trace( "normalizing terminal index access [" + textOrNull( collectionPath ) + "]" );
+ PathedPropertyReferenceSource collectionSource = ( PathedPropertyReferenceSource ) collectionPath.getFirstChild();
+ Ident collectionProperty = ( Ident ) collectionSource.getNextSibling();
+ return pathNormalizationStrategyStack.getCurrent().handleTerminalIndexAccess( collectionSource, collectionProperty, ( Node ) selector );
+ }
+ protected AST normalizeIndexOperation(AST collectionPropertyReference, AST selector) throws SemanticException {
+ PropertyReference propertyReference = ( PropertyReference ) collectionPropertyReference;
+ Type type = propertyReference.getSource().getPropertyType( propertyReference.getPropertyName() );
+ if ( !type.isCollectionType() ) {
+ throw new DetailedSemanticException( "Not a collection property reference", collectionPropertyReference );
+ }
+
+ // todo : validate the selector type against the indexed collection's key type?
+
+ Join join = getPropertyJoinBuilder().buildIndexOperationJoin(
+ propertyReference.getSource().locatePersisterReference(),
+ propertyReference.getPropertyName(),
+ null,
+ ( Node ) getASTFactory().create( INNER, "inner" ),
+ ( Node ) selector
+ );
+
+ return join.locateRhs();
+ }
+
+ protected AST normalizeIndexedRoot(AST root) {
+// return super.normalizeIndexedRoot( alias );
+ return root;
+ }
+
protected void pushFromClausePropertyPathContext(AST joinTypeNode, AST fetch, AST alias, AST propertyFetch) {
pathNormalizationStrategyStack.push(
new FromClausePathNormalizationStrategy(
@@ -332,8 +421,8 @@
popPathNormalizationContext();
}
- private void popPathNormalizationContext() {
- pathNormalizationStrategyStack.pop();
+ private PathNormalizationStrategy popPathNormalizationContext() {
+ return pathNormalizationStrategyStack.pop();
}
protected void pushSelectClausePropertyPathContext() {
@@ -350,8 +439,9 @@
);
}
- protected void popOnFragmentPropertyPathContext() {
- popPathNormalizationContext();
+ protected AST popOnFragmentPropertyPathContext() {
+ OnFragmentPathNormalizationStrategy strategy = ( OnFragmentPathNormalizationStrategy ) popPathNormalizationContext();
+ return strategy.getDiscoveredLHS();
}
protected void pushWithFragmentPropertyPathContext(AST rhsPropertyReference) {
@@ -371,4 +461,115 @@
protected void applyWithFragment(AST withFragment) {
( ( WithFragmentPathNormalizationStrategy ) pathNormalizationStrategyStack.getCurrent() ).applyWithFragment( withFragment );
}
+
+ protected void postProcessQuery(AST querySpec) {
+ AST selectFrom = querySpec.getFirstChild();
+ assert selectFrom.getType() == SELECT_FROM;
+
+ AST fromClause = selectFrom.getFirstChild();
+ assert fromClause.getType() == FROM;
+
+ AST selectClause = fromClause.getNextSibling();
+ assert selectClause == null || selectClause.getType() == SELECT;
+
+ if ( selectClause == null || selectClause.getNumberOfChildren() == 0 ) {
+ selectClause = generateDerivedSelectClause( fromClause );
+ fromClause.setNextSibling( selectClause );
+ }
+
+ if ( propertyFetchAliases != null && !propertyFetchAliases.isEmpty() ) {
+ AST fetches = astFactory.create( FETCH, "fetch-aliases" );
+ Iterator aliases = propertyFetchAliases.iterator();
+ while ( aliases.hasNext() ) {
+ final String alias = ( String ) aliases.next();
+ fetches.addChild( astFactory.create( ALIAS_REF, alias ) );
+ }
+ selectClause.addChild( fetches );
+ propertyFetchAliases.clear();
+ }
+
+ // todo : attach mapping-defined order-by fragments
+ // an issue here is that order-by fragments are attached "above" the "query spec" level according to ANSI SQL
+ // for example, an order by is a function of the combined result in the case of a UNION, INTERSECT, etc...
+
+ }
+
+ private AST generateDerivedSelectClause(AST fromClause) {
+ AST selectClause = astFactory.create( SELECT, "derived-select-clause" );
+ AST selectList = astFactory.create( SELECT_LIST, "derived-select-list" );
+ selectClause.setFirstChild( selectList );
+
+ List implicitlySelectedPersisterReferenceAliases =
+ getCurrentPersisterReferenceContext().getPersisterReferencesImplicitInDerivedSelectClause();
+ assert implicitlySelectedPersisterReferenceAliases != null : "Found no registered implied select references";
+
+
+ Iterator itr = implicitlySelectedPersisterReferenceAliases.iterator();
+ while ( itr.hasNext() ) {
+ final PersisterReference persisterReference = ( PersisterReference ) itr.next();
+ final String alias = persisterReference.getAlias();
+ AST aliasReference = astFactory.create( ALIAS_REF, alias );
+ AST selectItem = astFactory.create( SELECT_ITEM, "derived-select-item" );
+ selectItem.setFirstChild( aliasReference );
+ selectList.addChild( selectItem );
+ }
+
+ return selectClause;
+ }
+
+ protected void registerSelectItem(AST selectItem) {
+ // todo : this was intended to allow for reusing select elements in other clauses, like say an order by
+ trace( "registering select item" );
+ }
+
+ protected AST buildRootEntityPersisterReference(AST persisterReferenceNode, AST entityName, AST alias, AST filter, AST propertyFetch) {
+ PersisterReference ref = ( PersisterReference ) super.buildRootEntityPersisterReference(
+ persisterReferenceNode,
+ entityName,
+ alias,
+ filter,
+ propertyFetch
+ );
+
+ if ( filter != null ) {
+ log.trace( "applying filter [" + filter.getText() + ", " + entityName + "]" );
+ }
+
+ getCurrentPersisterReferenceContext().registerPersisterReferenceImplicitInDerivedSelectClause( ref );
+
+ return ref;
+ }
+
+ private List propertyFetchAliases;
+
+ protected void registerPropertyFetchNode(AST persisterReference) {
+ if ( propertyFetchAliases == null ) {
+ propertyFetchAliases = new ArrayList();
+ }
+ propertyFetchAliases.add( ( ( PersisterReference ) persisterReference ).getAlias() );
+ }
+
+
+ // AST output methods ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public void dumpAst(AST ast) {
+ dumpAst( ast, "DUMP" );
+ }
+
+ public void dumpAst(AST ast, String header) {
+ log.info( printer.showAsString( ast, header ) );
+ }
+
+ public void showAst(AST ast, PrintStream out) {
+ showAst( ast, new PrintWriter( out ) );
+ }
+
+ private void showAst(AST ast, PrintWriter pw) {
+ printer.showAst( ast, pw );
+ }
+
+
+ private String textOrNull(AST ast) {
+ return ast == null ? null : ast.getText();
+ }
}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexCollectionElementReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexCollectionElementReference.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexCollectionElementReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import org.hibernate.sql.ast.common.Node;
+
+/**
+ * Models the terminal reference to an index operator.
+ *
+ * @author Steve Ebersole
+ */
+public class IndexCollectionElementReference extends Node implements PropertyPathTerminus {
+}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexedCollectionElementAccessPersisterReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexedCollectionElementAccessPersisterReference.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/IndexedCollectionElementAccessPersisterReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,101 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import org.hibernate.type.AssociationType;
+import org.hibernate.type.Type;
+import org.hibernate.persister.collection.QueryableCollection;
+import org.hibernate.persister.entity.Queryable;
+import org.hibernate.AssertionFailure;
+
+/**
+ * Models the concept of a reference to the element persister of an indexed collection (map, list) which has been
+ * accessed or restricted by an index operation.
+ *
+ * @author Steve Ebersole
+ */
+public class IndexedCollectionElementAccessPersisterReference extends AbstractPersisterReference {
+ private transient QueryableCollection collectionPersister;
+ private transient Queryable elementPersister;
+
+ /**
+ * Retrieve the collection "role" identifying the underlying {@link org.hibernate.persister.collection.CollectionPersister}
+ *
+ * @return The collection role
+ */
+ public String getCollectionRole() {
+ return getFirstChild().getText();
+ }
+
+ public String getName() {
+ return getCollectionRole() + "[]";
+ }
+
+ public boolean isCollection() {
+ return false;
+ }
+
+ public AssociationType getPersisterType() {
+ return elementPersister() == null
+ ? null
+ : ( AssociationType ) elementPersister().getType();
+ }
+
+ public QueryableCollection collectionPersister() {
+ if ( collectionPersister == null ) {
+ collectionPersister = ( QueryableCollection ) normalizationContext().getSessionFactoryImplementor()
+ .getCollectionPersister( getCollectionRole() );
+ }
+ return collectionPersister;
+ }
+
+ public Queryable elementPersister() {
+ if ( elementPersister == null ) {
+ try {
+ elementPersister = ( Queryable ) collectionPersister().getElementPersister();
+ }
+ catch ( AssertionFailure ignore ) {
+ // leave it null
+ }
+ }
+ return elementPersister;
+ }
+
+ public Type getPropertyType(String propertyName) {
+ try {
+ return elementPersister().getPropertyType( propertyName );
+ }
+ catch( Throwable ignore ) {
+ return null;
+ }
+ }
+
+ public boolean containsProperty(String propertyName) {
+ return getPropertyType( propertyName ) != null;
+ }
+
+ public Type getCollectionIndexType() {
+ return collectionPersister().getIndexType();
+ }
+}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Join.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Join.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/Join.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -33,26 +33,12 @@
*
* @author Steve Ebersole
*/
-public class Join extends Node {
- private boolean forced = false;
+public interface Join extends AST {
+ public Node locateJoinType();
- public void force() {
- forced = true;
- }
+ public JoinType getEnumeratedJoinType();
- public boolean isForced() {
- return forced;
- }
+ public Node locateJoinedProperty();
- public Node getJoinType() {
- return ( Node ) getFirstChild();
- }
-
- public JoinType getEnumeratedJoinType() {
- return JoinType.resolve( getJoinType() );
- }
-
- public PersisterReference getRhs() {
- return ( PersisterReference ) getFirstChild().getNextSibling();
- }
+ public PersisterReference locateRhs();
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContext.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContext.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContext.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -27,6 +27,8 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.sql.ast.util.ASTPrinter;
+import org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy;
+import org.hibernate.sql.ast.alias.ImplicitAliasGenerator;
/**
* Defines the environment or context in which normalization is occuring, more specifically
@@ -54,7 +56,7 @@
*
* @return The alias builder.
*/
- public AliasBuilder getAliasBuilder();
+ public ImplicitAliasGenerator getAliasBuilder();
/**
* The current {@link PersisterReferenceContext} for this context. The {@link PersisterReferenceContext}
@@ -72,6 +74,13 @@
public PersisterReferenceBuilder getPersisterReferenceBuilder();
/**
+ * The builder of {@link Join} instances pertaining to property joins for this context.
+ *
+ * @return The property {@link Join} builder.
+ */
+ public PropertyJoinBuilder getPropertyJoinBuilder();
+
+ /**
* The AST printer available for this context.
*
* @return The AST printer.
@@ -84,4 +93,10 @@
* @return True or false.
*/
public boolean isCurrentlyProcessingFunction();
+
+ public PathNormalizationStrategy getCurrentPathNormalizationStrategy();
+
+ public void registerAssociationFetch(Join join);
+
+ public void registerPropertyFetch(PersisterReference persisterReference);
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContextAwareNode.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContextAwareNode.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizationContextAwareNode.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -35,5 +35,5 @@
*
* @param resolutionContext The resolution context.
*/
- public void injectResolutionContext(NormalizationContext resolutionContext);
+ public void injectNormalizationContext(NormalizationContext resolutionContext);
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterAliasReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterAliasReference.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterAliasReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -27,26 +27,40 @@
import org.hibernate.type.Type;
/**
- * TODO : javadoc
+ * Represents a reference to a persister-reference alias.
*
* @author Steve Ebersole
*/
public class PersisterAliasReference extends Node implements PropertyReferenceSource, NormalizationContextAwareNode {
private NormalizationContext resolutionContext;
+ /**
+ * Retrieves the alias.
+ *
+ * @return The alias.
+ */
public String getPersisterAlias() {
return getText();
}
+ /**
+ * {@inheritDoc}
+ */
public PersisterReference locatePersisterReference() {
return resolutionContext.getCurrentPersisterReferenceContext()
.locatePersisterReferenceByAlias( getPersisterAlias() );
}
- public void injectResolutionContext(NormalizationContext resolutionContext) {
+ /**
+ * {@inheritDoc}
+ */
+ public void injectNormalizationContext(NormalizationContext resolutionContext) {
this.resolutionContext = resolutionContext;
}
+ /**
+ * {@inheritDoc}
+ */
public Type getPropertyType(String property) {
return locatePersisterReference().getPropertyType( property );
}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterJoin.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterJoin.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterJoin.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import org.hibernate.sql.ast.common.Node;
+import org.hibernate.sql.ast.common.JoinType;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class PersisterJoin extends Node implements Join {
+ public Node locateJoinType() {
+ return ( Node ) getFirstChild();
+ }
+
+ public JoinType getEnumeratedJoinType() {
+ return JoinType.resolve( locateJoinType() );
+ }
+
+ public Node locateJoinedProperty() {
+ return null;
+ }
+
+ public PersisterReference locateRhs() {
+ return ( PersisterReference ) locateJoinType().getNextSibling();
+ }
+}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReference.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -36,14 +36,15 @@
public interface PersisterReference extends AST, PropertyReferenceSource {
/**
* Get the alias assigned to this persister reference. May be explcitly defined by the query author or
- * supplied by {@link AliasBuilder#buildUniqueImplicitAlias()}, but all persister references will have an alias.
+ * supplied by {@link org.hibernate.sql.ast.alias.ImplicitAliasGenerator#buildUniqueImplicitAlias()}, but all persister references will have an alias.
*
* @return This persister reference's alias.
*/
public String getAlias();
/**
- * Get the name of this persister reference.
+ * Get the name of this persister reference. This is just some descriptive text.
+ *
* @return The name.
*/
public String getName();
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceBuilder.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceBuilder.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceBuilder.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -23,23 +23,23 @@
*/
package org.hibernate.sql.ast.phase.hql.normalize;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import antlr.ASTFactory;
+import antlr.collections.AST;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.MappingException;
import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.sql.ast.alias.ImplicitAliasGenerator;
-import antlr.collections.AST;
-import antlr.ASTFactory;
-
/**
* Centralization of code needed to build a {@link PersisterReference}
*
* @author Steve Ebersole
*/
public class PersisterReferenceBuilder implements HqlNormalizeTokenTypes {
- public static final Log log = LogFactory.getLog( PersisterReferenceBuilder.class );
+ private static final Logger log = LoggerFactory.getLogger( PersisterReferenceBuilder.class );
private final NormalizationContext normalizationContext;
@@ -55,7 +55,7 @@
return normalizationContext.getCurrentPersisterReferenceContext();
}
- private AliasBuilder aliasBuilder() {
+ private ImplicitAliasGenerator aliasBuilder() {
return normalizationContext.getAliasBuilder();
}
@@ -70,13 +70,11 @@
*
* @param entityName The entity name to which to build a PersisterReference.
* @param alias The alias (or null) to apply to the built PersisterReference.
- * @param propertyFetching Whether lazy property fetching should be enabled.
* @return The built PersisterReference
*/
public EntityPersisterReference buildEntityPersisterReference(
String entityName,
- String alias,
- boolean propertyFetching) {
+ String alias) {
EntityPersister persister = lookupEntityPersister( entityName );
String aliasText = determineAlias( alias );
@@ -85,9 +83,6 @@
AST persisterReference = astFactory().create( ENTITY_PERSISTER_REF );
persisterReference.setFirstChild( entityNameNode );
persisterReference.addChild( aliasNode );
- if ( propertyFetching ) {
- persisterReference.addChild( astFactory().create( PROP_FETCH ) );
- }
EntityPersisterReference entityPersisterReference = ( EntityPersisterReference ) persisterReference;
persisterReferenceContext().registerPersisterReference( entityPersisterReference );
@@ -100,13 +95,11 @@
* @param collectionRole The {@link org.hibernate.persister.collection.CollectionPersister#getRole() collection role}
* for which to build a PersisterReference.
* @param alias The alias (or null) to apply to the built PersisterReference.
- * @param propertyFetching Whether lazy property fetching should be enabled.
* @return The built PersisterReference
*/
public CollectionPersisterReference buildCollectionPersisterReference(
String collectionRole,
- String alias,
- boolean propertyFetching) {
+ String alias) {
// todo : is this the structure we want here?
String aliasText = determineAlias( alias );
@@ -115,16 +108,35 @@
AST persisterReference = astFactory().create( COLLECTION_PERSISTER_REF );
persisterReference.setFirstChild( collectionRoleNode );
persisterReference.addChild( aliasNode );
- if ( propertyFetching ) {
- persisterReference.addChild( astFactory().create( PROP_FETCH ) );
- }
-
CollectionPersisterReference collectionPersisterReference = ( CollectionPersisterReference ) persisterReference;
persisterReferenceContext().registerPersisterReference( collectionPersisterReference );
return collectionPersisterReference;
}
+ public IndexedCollectionElementAccessPersisterReference buildIndexedCollectionElementAccessPersisterReference(
+ String collectionRole,
+ String alias,
+ AST selector) {
+ String aliasText = determineAlias( alias );
+
+ AST collectionRoleNode = astFactory().create( COLLECTION_ROLE, collectionRole );
+ AST aliasNode = astFactory().create( ALIAS, aliasText );
+
+ AST indexValueCondition = astFactory().create( INDEX_VALUE_CORRELATION, "index-correlation" );
+ indexValueCondition.addChild( selector );
+
+ AST persisterReference = astFactory().create( INDEXED_COLLECTION_ACCESS_PERSISTER_REF );
+ persisterReference.setFirstChild( collectionRoleNode );
+ persisterReference.addChild( aliasNode );
+ persisterReference.addChild( indexValueCondition );
+
+ IndexedCollectionElementAccessPersisterReference pr = ( IndexedCollectionElementAccessPersisterReference ) persisterReference;
+ persisterReferenceContext().registerPersisterReference( pr );
+
+ return pr;
+ }
+
private EntityPersister lookupEntityPersister(String name) {
// NOTE : the parser should have already normalized the entity name...
try {
@@ -156,7 +168,7 @@
}
public static boolean isImplicitAlias(String alias) {
- return AliasBuilder.isImplicitAlias( alias );
+ return ImplicitAliasGenerator.isImplicitAlias( alias );
}
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceContext.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceContext.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PersisterReferenceContext.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -23,6 +23,8 @@
*/
package org.hibernate.sql.ast.phase.hql.normalize;
+import java.util.List;
+
/**
* TODO : javadoc
*
@@ -78,4 +80,8 @@
*/
public void registerPersisterReference(PersisterReference persisterReference);
+ public void registerPersisterReferenceImplicitInDerivedSelectClause(PersisterReference persisterReference);
+
+ public List getPersisterReferencesImplicitInDerivedSelectClause();
+
}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoin.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoin.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoin.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,50 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import org.hibernate.sql.ast.common.Node;
+import org.hibernate.sql.ast.common.JoinType;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class PropertyJoin extends Node implements Join {
+ public Node locateJoinType() {
+ return ( Node ) getFirstChild();
+ }
+
+ public JoinType getEnumeratedJoinType() {
+ return JoinType.resolve( locateJoinType() );
+ }
+
+ public Node locateJoinedProperty() {
+ return ( Node ) locateJoinType().getNextSibling();
+ }
+
+ public PersisterReference locateRhs() {
+ return ( PersisterReference ) locateJoinedProperty().getNextSibling();
+ }
+}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoinBuilder.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoinBuilder.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyJoinBuilder.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,217 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import org.hibernate.type.Type;
+import org.hibernate.type.CollectionType;
+import org.hibernate.type.EntityType;
+import org.hibernate.HibernateException;
+import org.hibernate.sql.ast.util.ASTPrinter;
+import org.hibernate.sql.ast.common.Node;
+import org.hibernate.sql.ast.alias.ImplicitAliasGenerator;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class PropertyJoinBuilder implements HqlNormalizeTokenTypes {
+ private static final Logger log = LoggerFactory.getLogger( PropertyJoinBuilder.class );
+
+ private final NormalizationContext normalizationContext;
+
+ public PropertyJoinBuilder(NormalizationContext normalizationContext) {
+ this.normalizationContext = normalizationContext;
+ }
+
+ /**
+ * Build a property join node.
+ *
+ * @param lhs The join's left-hand-side persister-reference
+ * @param propertyName The property name.
+ * @param alias The alias to apply to the rhs of the join
+ * @param joinType The type of join (INNER, etc) to produce.
+ * @param propertyFetching should property fetching be applied to the joined persister?
+ * @param associationFetching Should the association making up the property join also be fetched?
+ *
+ * @return The right-hand-side persister-reference.
+ */
+ public Join buildPropertyJoin(
+ PersisterReference lhs,
+ String propertyName,
+ String alias,
+ Node joinType,
+ boolean propertyFetching,
+ boolean associationFetching) {
+ PersisterReference rhs;
+ final Type associationType = lhs.getPropertyType( propertyName );
+ if ( associationType.isCollectionType() ) {
+ CollectionType collectionType = ( CollectionType ) associationType;
+ rhs = persisterReferenceBuilder().buildCollectionPersisterReference(
+ collectionType.getRole(),
+ alias
+ );
+ }
+ else if ( associationType.isEntityType() ) {
+ EntityType entityType = ( EntityType ) associationType;
+ String entityName = entityType.getAssociatedEntityName( sessionFactoryImplementor() );
+ rhs = persisterReferenceBuilder().buildEntityPersisterReference( entityName, alias );
+ }
+ else {
+ throw new HibernateException(
+ "cannot create join on non-association [root=" + lhs.getAlias()
+ + ", name=" + propertyName
+ + ", type=" + associationType.getName() + "]"
+ );
+ }
+
+ if ( propertyFetching ) {
+ normalizationContext.registerPropertyFetch( rhs );
+ }
+
+ Join joinNode = buildJoinNode( lhs, rhs, propertyName, joinType, associationFetching );
+
+
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ printer().showAsString(
+ joinNode,
+ "implicit join : " + lhs.getAlias() + "." + propertyName
+ )
+ );
+ }
+
+ return joinNode;
+ }
+
+ public Join buildIndexOperationJoin(
+ PersisterReference lhs,
+ String collectionPropertyName,
+ String alias,
+ Node joinType,
+ Node selector) {
+ final Type associationType = lhs.getPropertyType( collectionPropertyName );
+ if ( !associationType.isCollectionType() ) {
+ throw new HibernateException(
+ "Cannot process index operation against a non-collection property [root=" + lhs.getAlias() +
+ ", name=" + collectionPropertyName +
+ ", type=" + associationType.getName()
+ );
+ }
+
+ CollectionType collectionType = ( CollectionType ) associationType;
+ IndexedCollectionElementAccessPersisterReference rhs = persisterReferenceBuilder().buildIndexedCollectionElementAccessPersisterReference(
+ collectionType.getRole(),
+ alias,
+ selector
+ );
+ if ( rhs.getCollectionIndexType() == null ) {
+ throw new HibernateException(
+ "Cannot process index operation against a non-indexed collection property [root=" + lhs.getAlias() +
+ ", name=" + collectionPropertyName +
+ ", type=" + associationType.getName()
+ );
+ }
+
+ Join joinNode = buildJoinNode( lhs, rhs, collectionPropertyName, joinType, false );
+
+ if ( log.isTraceEnabled() ) {
+ log.trace(
+ printer().showAsString(
+ joinNode,
+ "implicit join : " + lhs.getAlias() + "." + collectionPropertyName + "[]"
+ )
+ );
+ }
+
+ return joinNode;
+ }
+
+
+ private Join buildJoinNode(
+ PersisterReference lhs,
+ PersisterReference rhs,
+ String propertyName,
+ Node joinType,
+ boolean associationFetching) {
+ Join joinNode = ( Join ) createNode( PROPERTY_JOIN, "join" );
+ joinNode.setFirstChild( joinType );
+ joinNode.addChild( createNode( ASSOCIATION_NAME, propertyName ) );
+ joinNode.addChild( rhs );
+
+ if ( associationFetching ) {
+ normalizationContext.registerAssociationFetch( joinNode );
+ }
+
+ lhs.addChild( joinNode );
+
+ return joinNode;
+ }
+
+ // normalization context ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected final Node createNode(int type, String text) {
+ return ( Node ) normalizationContext.getASTFactory().create( type, text );
+ }
+
+ /**
+ * Getter for property 'aliasBuilder'.
+ *
+ * @return Value for property 'aliasBuilder'.
+ */
+ protected final ImplicitAliasGenerator aliasBuilder() {
+ return normalizationContext.getAliasBuilder();
+ }
+
+ /**
+ * Getter for property 'persisterReferenceBuilder'.
+ *
+ * @return Value for property 'persisterReferenceBuilder'.
+ */
+ protected final PersisterReferenceBuilder persisterReferenceBuilder() {
+ return normalizationContext.getPersisterReferenceBuilder();
+ }
+
+ /**
+ * Getter for property 'sessionFactoryImplementor'.
+ *
+ * @return Value for property 'sessionFactoryImplementor'.
+ */
+ protected final SessionFactoryImplementor sessionFactoryImplementor() {
+ return normalizationContext.getSessionFactoryImplementor();
+ }
+
+ /**
+ * Getter for property 'ASTPrinter'.
+ *
+ * @return Value for property 'ASTPrinter'.
+ */
+ protected final ASTPrinter printer() {
+ return normalizationContext.getPrinter();
+ }
+}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyPathTerminus.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyPathTerminus.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyPathTerminus.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,34 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import antlr.collections.AST;
+
+/**
+ * Represents the terminal part of a property path.
+ *
+ * @author Steve Ebersole
+ */
+public interface PropertyPathTerminus extends AST {
+}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyReference.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyReference.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/PropertyReference.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -31,7 +31,7 @@
*
* @author Steve Ebersole
*/
-public class PropertyReference extends Node {
+public class PropertyReference extends Node implements PropertyPathTerminus {
private String originalPath;
public String getOriginalPath() {
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/RootPersisterReferenceContext.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/RootPersisterReferenceContext.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/RootPersisterReferenceContext.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -47,6 +47,7 @@
private static final Logger log = LoggerFactory.getLogger( RootPersisterReferenceContext.class );
private List persisterReferences = new ArrayList();
+ private List persisterReferencesImplicitInDerivedSelectClause;
private Map aliasXref = new HashMap();
/**
@@ -63,6 +64,23 @@
/**
* {@inheritDoc}
*/
+ public void registerPersisterReferenceImplicitInDerivedSelectClause(PersisterReference persisterReference) {
+ if ( persisterReferencesImplicitInDerivedSelectClause == null ) {
+ persisterReferencesImplicitInDerivedSelectClause = new ArrayList();
+ }
+ persisterReferencesImplicitInDerivedSelectClause.add( persisterReference );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getPersisterReferencesImplicitInDerivedSelectClause() {
+ return persisterReferencesImplicitInDerivedSelectClause;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean isContainedAlias(String alias) {
return aliasXref.containsKey( alias );
}
Added: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/StatementStack.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/StatementStack.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/StatementStack.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,47 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.normalize;
+
+import java.util.LinkedList;
+
+/**
+ * Provides a stack of {@link Statement} nodes
+ *
+ * @author Steve Ebersole
+ */
+public class StatementStack {
+ private LinkedList stack = new LinkedList();
+
+ public void push(Statement statement) {
+ stack.addFirst( statement );
+ }
+
+ public Statement pop() {
+ return ( Statement ) stack.removeFirst();
+ }
+
+ public Statement getCurrent() {
+ return ( Statement ) stack.getFirst();
+ }
+}
Deleted: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/AbstractPathNormalizationStrategy.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/AbstractPathNormalizationStrategy.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/AbstractPathNormalizationStrategy.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -1,422 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, 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.sql.ast.phase.hql.normalize.path;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.hibernate.sql.ast.phase.hql.normalize.PropertyReference;
-import org.hibernate.sql.ast.phase.hql.normalize.Ident;
-import org.hibernate.sql.ast.phase.hql.normalize.NormalizationContext;
-import org.hibernate.sql.ast.phase.hql.normalize.AliasBuilder;
-import org.hibernate.sql.ast.phase.hql.normalize.PersisterReferenceBuilder;
-import org.hibernate.sql.ast.phase.hql.normalize.PersisterReference;
-import org.hibernate.sql.ast.phase.hql.normalize.HqlNormalizeTokenTypes;
-import org.hibernate.sql.ast.phase.hql.normalize.Join;
-import org.hibernate.sql.ast.phase.hql.normalize.DuplicateAliasException;
-import org.hibernate.sql.ast.util.ASTPrinter;
-import org.hibernate.sql.ast.util.DisplayableNode;
-import org.hibernate.type.ComponentType;
-import org.hibernate.type.Type;
-import org.hibernate.type.CollectionType;
-import org.hibernate.type.EntityType;
-import org.hibernate.QueryException;
-import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionFactoryImplementor;
-
-import antlr.collections.AST;
-import antlr.CommonAST;
-import antlr.Token;
-
-/**
- * Abstract implementation of {@link PathNormalizationStrategy} providing convenience methods to actual
- * {@link PathNormalizationStrategy} implementors.
- *
- * @author Steve Ebersole
- */
-public abstract class AbstractPathNormalizationStrategy implements PathNormalizationStrategy, HqlNormalizeTokenTypes {
- private static final Logger log = LoggerFactory.getLogger( AbstractPathNormalizationStrategy.class );
-
- protected final NormalizationContext normalizationContext;
- private PersisterReference root; // todo whether we need this depends on how we deciode to structure the prop-joins...
- private String pathThusFar = null;
-
- protected AbstractPathNormalizationStrategy(NormalizationContext normalizationContext) {
- this.normalizationContext = normalizationContext;
- }
-
- /**
- * Getter for property 'root'.
- *
- * @return Value for property 'root'.
- */
- protected PersisterReference getRoot() {
- return root;
- }
-
-
- // normalization context ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- /**
- * Getter for property 'normalizationContext'.
- *
- * @return Value for property 'normalizationContext'.
- */
- protected NormalizationContext getNormalizationContext() {
- return normalizationContext;
- }
-
- protected final AST createNode(int type, String text) {
- return getNormalizationContext().getASTFactory().create( type, text );
- }
-
- /**
- * Getter for property 'aliasBuilder'.
- *
- * @return Value for property 'aliasBuilder'.
- */
- protected final AliasBuilder getAliasBuilder() {
- return getNormalizationContext().getAliasBuilder();
- }
-
- /**
- * Getter for property 'persisterReferenceBuilder'.
- *
- * @return Value for property 'persisterReferenceBuilder'.
- */
- protected final PersisterReferenceBuilder getPersisterReferenceBuilder() {
- return getNormalizationContext().getPersisterReferenceBuilder();
- }
-
- /**
- * Getter for property 'sessionFactoryImplementor'.
- *
- * @return Value for property 'sessionFactoryImplementor'.
- */
- protected final SessionFactoryImplementor getSessionFactoryImplementor() {
- return getNormalizationContext().getSessionFactoryImplementor();
- }
-
- /**
- * Getter for property 'ASTPrinter'.
- *
- * @return Value for property 'ASTPrinter'.
- */
- protected final ASTPrinter getASTPrinter() {
- return getNormalizationContext().getPrinter();
- }
-
-
- // path ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected void initializePathSoFar(String root) {
- pathThusFar = root;
- }
-
- /**
- * Getter for property 'pathThusFar'.
- *
- * @return Value for property 'pathThusFar'.
- */
- public String getPathThusFar() {
- return pathThusFar;
- }
-
- /**
- * {@inheritDoc}
- */
- public final PathedPropertyReferenceSource handleRoot(PersisterReference persisterReference) {
- initializePathSoFar( persisterReference.getAlias() );
- root = persisterReference;
- log.trace( "handling root path source [" + pathThusFar + "]" );
- return internalHandleRoot( persisterReference );
- }
-
- /**
- * Hook for subclasses to process the path root.
- *
- * @param persisterReference The persister defining the source root.
- * @return The appropriate property path source implementation.
- */
- protected abstract PathedPropertyReferenceSource internalHandleRoot(PersisterReference persisterReference);
-
- /**
- * {@inheritDoc}
- */
- public final PathedPropertyReferenceSource handleIntermediatePathPart(PathedPropertyReferenceSource source, Ident pathPart) {
- pathThusFar = ( pathThusFar == null ) ? pathPart.getText() : pathThusFar + "." + pathPart.getText();
- log.trace( "handling intermediate path source [" + pathThusFar + "]" );
- return internalResolveIntermediatePathPart( source, pathPart );
- }
-
- /**
- * Hook for subclasses to process an intermediate part of the path.
- *
- * @param source The source from which pathPart originates.
- * @param pathPart The name of the path part to be processed.
- * @return The appropriate property path source implementation.
- */
- protected PathedPropertyReferenceSource internalResolveIntermediatePathPart(PathedPropertyReferenceSource source, Ident pathPart) {
- return source.handleIntermediatePathPart( pathPart );
- }
-
- /**
- * {@inheritDoc}
- */
- public final PropertyReference handleTerminalPathPart(PathedPropertyReferenceSource source, Ident pathPart) {
- pathThusFar = ( pathThusFar == null ) ? pathPart.getText() : pathThusFar + "." + pathPart.getText();
- log.trace( "handling terminal path part [" + pathThusFar + "]" );
- try {
- return internalResolveTerminalPathPart( source, pathPart );
- }
- finally {
- pathThusFar = null;
- }
- }
-
- /**
- * Hook for subclasses to process the terminal (or ending) part of a path.
- *
- * @param source The source from which pathPart originates.
- * @param pathPart The name of the path part to be processed.
- * @return a {@link #PROPERTY_REF} node representing the normalized property path.
- */
- protected PropertyReference internalResolveTerminalPathPart(PathedPropertyReferenceSource source, Ident pathPart) {
- return source.handleTerminalPathPart( pathPart );
- }
-
- /**
- * Convenience method to locate the index of a component sub-property. The returned index is relative to
- * {@link ComponentType#getPropertyNames}.
- *
- * @param componentType The component type mapping.
- * @param subPropertyName The sub-property name.
- * @return The index.
- */
- protected final int locateComponentPropertyIndex(ComponentType componentType, Ident subPropertyName) {
- return locateComponentPropertyIndex( componentType, subPropertyName.getText() );
- }
-
- /**
- * Convenience method to locate the index of a component sub-property. The returned index is relative to
- * {@link ComponentType#getPropertyNames}.
- *
- * @param componentType The component type mapping.
- * @param subPropertyName The sub-property name.
- * @return The index.
- */
- protected static int locateComponentPropertyIndex(ComponentType componentType, String subPropertyName) {
- String[] componentPropertyNames = componentType.getPropertyNames();
- for ( int i = 0; i < componentPropertyNames.length; i++ ) {
- if ( componentPropertyNames[i].equals( subPropertyName ) ) {
- return i;
- }
- }
- throw new QueryException( "could not locate component property [" + subPropertyName + "]" );
- }
-
- /**
- * Generate a {@link #PROPERTY_REF} node.
- *
- * @param origin The persister from which the property originates.
- * @param propertyName The name of the property being referenced.
- * @return The {@link #PROPERTY_REF} node.
- */
- protected final PropertyReference generatePropertyReference(PersisterReference origin, String propertyName) {
- AST propertyReference = createNode( PROPERTY_REF, "property-reference" );
- propertyReference.addChild( createNode( ALIAS_REF, origin.getAlias() ) );
- propertyReference.addChild( createNode( IDENT, propertyName ) );
- return ( PropertyReference ) propertyReference;
- }
-
- /**
- * Locate (if property joins are reusable) or build an appropriate join.
- *
- * @param lhs The join lhs, which is the origin of the property.
- * @param propertyName The name of the property
- * @param alias The alias, if any, to apply to the generated RHS persister reference.
- * @param propertyFetching Should property fetching be applied to the generated RHS?
- * @param associationFetch Did this property join specify association fetching (join fetch)?
- * @return The appropriate join.
- */
- protected final Join locateOrBuildPropertyJoin(
- PersisterReference lhs,
- String propertyName,
- String alias,
- boolean propertyFetching,
- boolean associationFetch) {
- Join join = null;
-
- if ( areJoinsReusable() ) {
- join = lhs.locateReusablePropertyJoin( propertyName );
- }
-
- if ( join == null ) {
- join = buildPropertyJoin( lhs, propertyName, alias, propertyFetching, associationFetch );
- if ( areJoinsReusable() ) {
- lhs.registerReusablePropertyJoin( propertyName, join );
- }
- }
-
- return join;
- }
-
- /**
- * Build a property join node.
- *
- * @param lhs The join's left-hand-side persister-reference
- * @param propertyName The property name.
- * @param alias The alias to apply to the rhs of the join
- * @param propertyFetching should property fetching be applied to the joined persister?
- * @param associationFetch Should the association making up the property join also be fetched?
- *
- * @return The right-hand-side persister-reference.
- */
- protected Join buildPropertyJoin(
- PersisterReference lhs,
- String propertyName,
- String alias,
- boolean propertyFetching,
- boolean associationFetch) {
- validateJoinCreation( lhs, propertyName );
-
- PersisterReference rhs = null;
- final Type associationType = lhs.getPropertyType( propertyName );
- if ( associationType.isCollectionType() ) {
- CollectionType collectionType = ( CollectionType ) associationType;
- rhs = getPersisterReferenceBuilder().buildCollectionPersisterReference(
- collectionType.getRole(),
- alias,
- propertyFetching
- );
- }
- else if ( associationType.isEntityType() ) {
- EntityType entityType = ( EntityType ) associationType;
- String entityName = entityType.getAssociatedEntityName( getSessionFactoryImplementor() );
- rhs = getPersisterReferenceBuilder().buildEntityPersisterReference( entityName, alias, propertyFetching );
- }
- else {
- throw new HibernateException( "cannot create join on non-association [name=" + propertyName + ", type=" + associationType + "]" );
- }
-
- Join propertyJoinNode = ( Join ) createNode( JOIN, "join" );
- propertyJoinNode.setFirstChild( buildJoinTypeNode() );
- propertyJoinNode.addChild( rhs );
-
- // todo : handle mapped join conditions, adding them to the tree
-
- if ( associationFetch ) {
- registerAssociationFetch( propertyJoinNode );
- }
-
- if ( log.isTraceEnabled() ) {
- log.trace(
- getASTPrinter().showAsString(
- propertyJoinNode,
- "implicit join [" + lhs.getAlias() + "." + propertyName + "]"
- )
- );
- }
-
- lhs.addChild( propertyJoinNode );
-
- return propertyJoinNode;
- }
-
- /**
- * Hook to allow subclasses to disallow implicit join.
- *
- * @param origin The persister-reference which is the origin of the property
- * @param property The property resulting in a join.
- */
- protected void validateJoinCreation(PersisterReference origin, String property) {
- log.debug( "creating path expression implied join [" + origin.getAlias() + "].[" + property + "]" );
- }
-
- private void registerAssociationFetch(Join propertyJoinNode) {
- // todo : implement
- }
-
- /**
- * Hook to allow subclasses to define the type of join to use for an implciit join.
- * <p/>
- * The default is to use an {@link #INNER} join.
- *
- * @return The join type node.
- */
- protected AST buildJoinTypeNode() {
- return createNode( INNER, "inner" );
- }
-
- /**
- * Does this strategy allows property joins to be reused?
- *
- * @return True/false.
- */
- protected boolean areJoinsReusable() {
- return true;
- }
-
-
- // source impl support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- public abstract class AbstractPathedPropertyReferenceSource extends CommonAST
- implements PathedPropertyReferenceSource, DisplayableNode {
- private final String originationPath;
-
- /**
- * Constructs a new AbstractPathedPropertyReferenceSource.
- */
- protected AbstractPathedPropertyReferenceSource() {
- this( getPathThusFar() );
- }
-
- protected AbstractPathedPropertyReferenceSource(Token token) {
- this( token, getPathThusFar() );
- }
-
- protected AbstractPathedPropertyReferenceSource(String originationPath) {
- this.originationPath = originationPath;
- }
-
- protected AbstractPathedPropertyReferenceSource(Token token, String originationPath) {
- super( token );
- this.originationPath = originationPath;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getOriginationPath() {
- return originationPath;
- }
-
- /**
- * {@inheritDoc}
- */
- public final String getDisplayText() {
- return " ADPATER : SHOULD NEVER END UP IN TREE!";
- }
- }
-}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathNormalizationStrategy.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathNormalizationStrategy.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathNormalizationStrategy.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -24,12 +24,13 @@
package org.hibernate.sql.ast.phase.hql.normalize.path;
import org.hibernate.sql.ast.phase.hql.normalize.PersisterReference;
-import org.hibernate.sql.ast.phase.hql.normalize.PropertyReference;
import org.hibernate.sql.ast.phase.hql.normalize.Ident;
+import org.hibernate.sql.ast.phase.hql.normalize.PropertyPathTerminus;
+import org.hibernate.sql.ast.common.Node;
/**
* Applies a strategy pattern to the manner in which path expressions are normalized, allowing contextual pluggability
- * of the implicit-join handling rules...
+ * of the implicit-join and index-access handling rules...
*
* @author Steve Ebersole
*/
@@ -61,5 +62,9 @@
*
* @return The terminal property reference indicated by the overall path.
*/
- public PropertyReference handleTerminalPathPart(PathedPropertyReferenceSource source, Ident pathPart);
+ public PropertyPathTerminus handleTerminalPathPart(PathedPropertyReferenceSource source, Ident pathPart);
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(PathedPropertyReferenceSource source, Ident name, Node selector);
+
+ public PropertyPathTerminus handleTerminalIndexAccess(PathedPropertyReferenceSource source, Ident name, Node selector);
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathedPropertyReferenceSource.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathedPropertyReferenceSource.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/PathedPropertyReferenceSource.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -25,8 +25,9 @@
import antlr.collections.AST;
-import org.hibernate.sql.ast.phase.hql.normalize.PropertyReference;
import org.hibernate.sql.ast.phase.hql.normalize.Ident;
+import org.hibernate.sql.ast.phase.hql.normalize.PropertyPathTerminus;
+import org.hibernate.sql.ast.common.Node;
/**
* The contract for representing the non-terminal parts of a property path expression
@@ -60,5 +61,9 @@
*
* @return The property reference.
*/
- public PropertyReference handleTerminalPathPart(Ident name);
+ public PropertyPathTerminus handleTerminalPathPart(Ident name);
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector);
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector);
}
Copied: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/AbstractPathNormalizationStrategy.java (from rev 15747, core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/AbstractPathNormalizationStrategy.java)
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/AbstractPathNormalizationStrategy.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/AbstractPathNormalizationStrategy.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,448 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, 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.sql.ast.phase.hql.normalize.path.impl;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.sql.ast.phase.hql.normalize.PropertyReference;
+import org.hibernate.sql.ast.phase.hql.normalize.Ident;
+import org.hibernate.sql.ast.phase.hql.normalize.NormalizationContext;
+import org.hibernate.sql.ast.alias.ImplicitAliasGenerator;
+import org.hibernate.sql.ast.phase.hql.normalize.PersisterReferenceBuilder;
+import org.hibernate.sql.ast.phase.hql.normalize.PersisterReference;
+import org.hibernate.sql.ast.phase.hql.normalize.HqlNormalizeTokenTypes;
+import org.hibernate.sql.ast.phase.hql.normalize.Join;
+import org.hibernate.sql.ast.phase.hql.normalize.PropertyPathTerminus;
+import org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy;
+import org.hibernate.sql.ast.phase.hql.normalize.path.PathedPropertyReferenceSource;
+import org.hibernate.sql.ast.util.ASTPrinter;
+import org.hibernate.sql.ast.util.DisplayableNode;
+import org.hibernate.sql.ast.common.Node;
+import org.hibernate.type.ComponentType;
+import org.hibernate.QueryException;
+import org.hibernate.engine.SessionFactoryImplementor;
+
+import antlr.collections.AST;
+import antlr.CommonAST;
+import antlr.Token;
+
+/**
+ * Abstract implementation of {@link org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy} providing convenience methods to actual
+ * {@link org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy} implementors.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractPathNormalizationStrategy implements PathNormalizationStrategy, HqlNormalizeTokenTypes {
+ private static final Logger log = LoggerFactory.getLogger( AbstractPathNormalizationStrategy.class );
+
+ private final NormalizationContext normalizationContext;
+ private PersisterReference root; // todo whether we need this depends on how we deciode to structure the prop-joins...
+ private String pathThusFar = null;
+
+ protected AbstractPathNormalizationStrategy(NormalizationContext normalizationContext) {
+ this.normalizationContext = normalizationContext;
+ }
+
+ /**
+ * Getter for property 'root'.
+ *
+ * @return Value for property 'root'.
+ */
+ protected PersisterReference getRoot() {
+ return root;
+ }
+
+
+ // normalization context ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ /**
+ * Getter for property 'normalizationContext'.
+ *
+ * @return Value for property 'normalizationContext'.
+ */
+ protected NormalizationContext normalizationContext() {
+ return normalizationContext;
+ }
+
+ protected final Node createNode(int type, String text) {
+ return ( Node ) normalizationContext().getASTFactory().create( type, text );
+ }
+
+ /**
+ * Getter for property 'aliasBuilder'.
+ *
+ * @return Value for property 'aliasBuilder'.
+ */
+ protected final ImplicitAliasGenerator getAliasBuilder() {
+ return normalizationContext().getAliasBuilder();
+ }
+
+ /**
+ * Getter for property 'persisterReferenceBuilder'.
+ *
+ * @return Value for property 'persisterReferenceBuilder'.
+ */
+ protected final PersisterReferenceBuilder getPersisterReferenceBuilder() {
+ return normalizationContext().getPersisterReferenceBuilder();
+ }
+
+ /**
+ * Getter for property 'sessionFactoryImplementor'.
+ *
+ * @return Value for property 'sessionFactoryImplementor'.
+ */
+ protected final SessionFactoryImplementor getSessionFactoryImplementor() {
+ return normalizationContext().getSessionFactoryImplementor();
+ }
+
+ /**
+ * Getter for property 'ASTPrinter'.
+ *
+ * @return Value for property 'ASTPrinter'.
+ */
+ protected final ASTPrinter getASTPrinter() {
+ return normalizationContext().getPrinter();
+ }
+
+
+ // path ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ protected void initializePathSoFar(String root) {
+ pathThusFar = root;
+ }
+
+ /**
+ * Getter for property 'pathThusFar'.
+ *
+ * @return Value for property 'pathThusFar'.
+ */
+ public String getPathThusFar() {
+ return pathThusFar;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final PathedPropertyReferenceSource handleRoot(PersisterReference persisterReference) {
+ initializePathSoFar( persisterReference.getAlias() );
+ root = persisterReference;
+ log.trace( "handling root path source [" + pathThusFar + "]" );
+ return internalHandleRoot( persisterReference );
+ }
+
+ /**
+ * Hook for subclasses to process the path root.
+ *
+ * @param persisterReference The persister defining the source root.
+ * @return The appropriate property path source implementation.
+ */
+ protected abstract PathedPropertyReferenceSource internalHandleRoot(PersisterReference persisterReference);
+
+ /**
+ * {@inheritDoc}
+ */
+ public final PathedPropertyReferenceSource handleIntermediatePathPart(PathedPropertyReferenceSource source, Ident pathPart) {
+ pathThusFar = ( pathThusFar == null ) ? pathPart.getText() : pathThusFar + "." + pathPart.getText();
+ log.trace( "handling intermediate path source [" + pathThusFar + "]" );
+ return internalResolveIntermediatePathPart( source, pathPart );
+ }
+
+ /**
+ * Hook for subclasses to process an intermediate part of the path.
+ *
+ * @param source The source from which pathPart originates.
+ * @param pathPart The name of the path part to be processed.
+ * @return The appropriate property path source implementation.
+ */
+ protected PathedPropertyReferenceSource internalResolveIntermediatePathPart(PathedPropertyReferenceSource source, Ident pathPart) {
+ return source.handleIntermediatePathPart( pathPart );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final PropertyPathTerminus handleTerminalPathPart(PathedPropertyReferenceSource source, Ident pathPart) {
+ pathThusFar = ( pathThusFar == null ) ? pathPart.getText() : pathThusFar + "." + pathPart.getText();
+ log.trace( "handling terminal path part [" + pathThusFar + "]" );
+ try {
+ return internalResolveTerminalPathPart( source, pathPart );
+ }
+ finally {
+ pathThusFar = null;
+ }
+ }
+
+ /**
+ * Hook for subclasses to process the terminal (or ending) part of a path.
+ *
+ * @param source The source from which pathPart originates.
+ * @param pathPart The name of the path part to be processed.
+ * @return a node representing the normalized property path.
+ */
+ protected PropertyPathTerminus internalResolveTerminalPathPart(PathedPropertyReferenceSource source, Ident pathPart) {
+ return source.handleTerminalPathPart( pathPart );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final PathedPropertyReferenceSource handleIntermediateIndexAccess(PathedPropertyReferenceSource source, Ident pathPart, Node selector) {
+ pathThusFar = ( ( pathThusFar == null ) ? pathPart.getText() : pathThusFar + "." + pathPart.getText() ) + "[]";
+ log.trace( "handling intermediate index access [" + pathThusFar + "]" );
+ try {
+ return internalHandleIntermediateIndexAccess( source, pathPart, selector );
+ }
+ finally {
+ pathThusFar = null;
+ }
+ }
+
+ /**
+ * Hook for subclasses to process an index access as an intermediate property path.
+ *
+ * @param source The source from which pathPart originates.
+ * @param pathPart The name of the path part to be processed.
+ * @param selector The index selector to be appliedto the indexed collection
+ *
+ * @return The appropriate property path source implementation.
+ */
+ protected PathedPropertyReferenceSource internalHandleIntermediateIndexAccess(PathedPropertyReferenceSource source, Ident pathPart, Node selector) {
+ return source.handleIntermediateIndexAccess( pathPart, selector );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final PropertyPathTerminus handleTerminalIndexAccess(PathedPropertyReferenceSource source, Ident pathPart, Node selector) {
+ pathThusFar = ( ( pathThusFar == null ) ? pathPart.getText() : pathThusFar + "." + pathPart.getText() ) + "[]";
+ log.trace( "handling terminal index access [" + pathThusFar + "]" );
+ try {
+ return internalHandleTerminalIndexAccess( source, pathPart, selector );
+ }
+ finally {
+ pathThusFar = null;
+ }
+ }
+
+ /**
+ * Hook for subclasses to process an index access as the terminus of a property path.
+ *
+ * @param source The source from which pathPart originates.
+ * @param pathPart The name of the path part to be processed.
+ * @param selector The index selector to be appliedto the indexed collection
+ *
+ * @return a node representing the normalized property path.
+ */
+ protected PropertyPathTerminus internalHandleTerminalIndexAccess(PathedPropertyReferenceSource source, Ident pathPart, Node selector) {
+ return source.handleTerminalIndexAccess( pathPart, selector );
+ }
+
+ /**
+ * Convenience method to locate the index of a component sub-property. The returned index is relative to
+ * {@link ComponentType#getPropertyNames}.
+ *
+ * @param componentType The component type mapping.
+ * @param subPropertyName The sub-property name.
+ * @return The index.
+ */
+ protected final int locateComponentPropertyIndex(ComponentType componentType, Ident subPropertyName) {
+ return locateComponentPropertyIndex( componentType, subPropertyName.getText() );
+ }
+
+ /**
+ * Convenience method to locate the index of a component sub-property. The returned index is relative to
+ * {@link ComponentType#getPropertyNames}.
+ *
+ * @param componentType The component type mapping.
+ * @param subPropertyName The sub-property name.
+ * @return The index.
+ */
+ protected static int locateComponentPropertyIndex(ComponentType componentType, String subPropertyName) {
+ String[] componentPropertyNames = componentType.getPropertyNames();
+ for ( int i = 0; i < componentPropertyNames.length; i++ ) {
+ if ( componentPropertyNames[i].equals( subPropertyName ) ) {
+ return i;
+ }
+ }
+ throw new QueryException( "could not locate component property [" + subPropertyName + "]" );
+ }
+
+ /**
+ * Generate a {@link #PROPERTY_REF} node.
+ *
+ * @param origin The persister from which the property originates.
+ * @param propertyName The name of the property being referenced.
+ * @return The {@link #PROPERTY_REF} node.
+ */
+ protected final PropertyReference generatePropertyReference(PersisterReference origin, String propertyName) {
+ AST propertyReference = createNode( PROPERTY_REF, "property-reference" );
+ propertyReference.addChild( createNode( ALIAS_REF, origin.getAlias() ) );
+ propertyReference.addChild( createNode( IDENT, propertyName ) );
+ return ( PropertyReference ) propertyReference;
+ }
+
+ /**
+ * Locate (if property joins are reusable) or build an appropriate join.
+ *
+ * @param lhs The join lhs, which is the origin of the property.
+ * @param propertyName The name of the property
+ * @param alias The alias, if any, to apply to the generated RHS persister reference.
+ * @param propertyFetching Should property fetching be applied to the generated RHS?
+ * @param associationFetching Did this property join specify association fetching (join fetch)?
+ * @return The appropriate join.
+ */
+ protected final Join locateOrBuildPropertyJoin(
+ PersisterReference lhs,
+ String propertyName,
+ String alias,
+ boolean propertyFetching,
+ boolean associationFetching) {
+ Join join = null;
+
+ if ( areJoinsReusable() ) {
+ join = lhs.locateReusablePropertyJoin( propertyName );
+ }
+
+ if ( join == null ) {
+ join = buildPropertyJoin( lhs, propertyName, alias, propertyFetching, associationFetching );
+ if ( areJoinsReusable() ) {
+ lhs.registerReusablePropertyJoin( propertyName, join );
+ }
+ }
+
+ return join;
+ }
+
+ /**
+ * Build a property join node.
+ *
+ * @param lhs The join's left-hand-side persister-reference
+ * @param propertyName The property name.
+ * @param alias The alias to apply to the rhs of the join
+ * @param propertyFetching should property fetching be applied to the joined persister?
+ * @param associationFetching Should the association making up the property join also be fetched?
+ *
+ * @return The right-hand-side persister-reference.
+ */
+ protected Join buildPropertyJoin(
+ PersisterReference lhs,
+ String propertyName,
+ String alias,
+ boolean propertyFetching,
+ boolean associationFetching) {
+ validateJoinCreation( lhs, propertyName );
+ return normalizationContext().getPropertyJoinBuilder().buildPropertyJoin(
+ lhs,
+ propertyName,
+ alias,
+ buildJoinTypeNode(),
+ propertyFetching,
+ associationFetching
+ );
+ }
+
+ /**
+ * Hook to allow subclasses to disallow implicit join.
+ *
+ * @param origin The persister-reference which is the origin of the property
+ * @param property The property resulting in a join.
+ */
+ protected void validateJoinCreation(PersisterReference origin, String property) {
+ log.debug( "creating path expression implied join [" + origin.getAlias() + "].[" + property + "]" );
+ }
+
+ /**
+ * Hook to allow subclasses to define the type of join to use for an implciit join.
+ * <p/>
+ * The default is to use an {@link #INNER} join.
+ *
+ * @return The join type node.
+ */
+ protected Node buildJoinTypeNode() {
+ return createNode( INNER, "inner" );
+ }
+
+ /**
+ * Does this strategy allows property joins to be reused?
+ *
+ * @return True/false.
+ */
+ protected boolean areJoinsReusable() {
+ return true;
+ }
+
+
+ // source impl support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ public abstract class AbstractPathedPropertyReferenceSource extends CommonAST
+ implements PathedPropertyReferenceSource, DisplayableNode {
+ private final String originationPath;
+
+ /**
+ * Constructs a new AbstractPathedPropertyReferenceSource.
+ */
+ protected AbstractPathedPropertyReferenceSource() {
+ this( getPathThusFar() );
+ }
+
+ protected AbstractPathedPropertyReferenceSource(Token token) {
+ this( token, getPathThusFar() );
+ }
+
+ protected AbstractPathedPropertyReferenceSource(String originationPath) {
+ this.originationPath = originationPath;
+ }
+
+ protected AbstractPathedPropertyReferenceSource(Token token, String originationPath) {
+ super( token );
+ this.originationPath = originationPath;
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(PersisterReference lhs, Ident name, Node selector) {
+ Join join = normalizationContext().getPropertyJoinBuilder().buildIndexOperationJoin(
+ lhs,
+ name.getText(),
+ null,
+ buildJoinTypeNode(),
+ selector
+ );
+ return ( PropertyPathTerminus ) createNode( INDEXED_COLLECTION_ELEMENT_REF, join.locateRhs().getAlias() );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getOriginationPath() {
+ return originationPath;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public final String getDisplayText() {
+ return " ADPATER : SHOULD NEVER END UP IN TREE!";
+ }
+ }
+}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/BasicPathNormalizationStrategySupport.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/BasicPathNormalizationStrategySupport.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/BasicPathNormalizationStrategySupport.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -29,10 +29,12 @@
import org.hibernate.sql.ast.phase.hql.normalize.PersisterReference;
import org.hibernate.sql.ast.phase.hql.normalize.NormalizationContext;
import org.hibernate.sql.ast.phase.hql.normalize.Ident;
-import org.hibernate.sql.ast.phase.hql.normalize.PropertyReference;
import org.hibernate.sql.ast.phase.hql.normalize.Join;
-import org.hibernate.sql.ast.phase.hql.normalize.path.AbstractPathNormalizationStrategy;
+import org.hibernate.sql.ast.phase.hql.normalize.IndexedCollectionElementAccessPersisterReference;
+import org.hibernate.sql.ast.phase.hql.normalize.PropertyPathTerminus;
+import org.hibernate.sql.ast.phase.hql.normalize.path.impl.AbstractPathNormalizationStrategy;
import org.hibernate.sql.ast.phase.hql.normalize.path.PathedPropertyReferenceSource;
+import org.hibernate.sql.ast.common.Node;
import org.hibernate.type.Type;
import org.hibernate.type.ComponentType;
import org.hibernate.type.EntityType;
@@ -128,7 +130,7 @@
return determineAppropriateIntermediateSourceType( lhs, name );
}
- public PropertyReference handleTerminalPathPart(Ident name) {
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
final String nameText = name.getText();
if ( lhs.getPropertyType( nameText ).isEntityType() ) {
if ( shouldTerminalEntityPropertyForceJoin() ) {
@@ -138,6 +140,21 @@
return generatePropertyReference( lhs, name.getText() );
}
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ Join join = normalizationContext().getPropertyJoinBuilder().buildIndexOperationJoin(
+ lhs,
+ name.getText(),
+ null,
+ buildJoinTypeNode(),
+ selector
+ );
+ return new IndexAccessIntermediatePathSource( join.locateRhs() );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ return super.handleTerminalIndexAccess( lhs, name, selector );
+ }
+
public String getText() {
return "root-source {" + lhs.getAlias() + "}";
}
@@ -148,9 +165,17 @@
throw new HibernateException( "cannot dereference simple value as part of path expression" );
}
- public PropertyReference handleTerminalPathPart(Ident name) {
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
throw new HibernateException( "cannot dereference simple value as part of path expression" );
}
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ throw new HibernateException( "cannot apply index operation to simple value" );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ throw new HibernateException( "cannot apply index operation to simple value" );
+ }
}
private class ComponentIntermediatePathSource extends AbstractPathedPropertyReferenceSource {
@@ -184,10 +209,18 @@
}
}
- public PropertyReference handleTerminalPathPart(Ident name) {
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
return generatePropertyReference( lhs, buildComponentDereferencePath( name.getText() ) );
}
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ throw new HibernateException( "cannot apply index operation to component value" );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ throw new HibernateException( "cannot apply index operation to component value" );
+ }
+
private String buildComponentDereferencePath(String subPropertyName) {
return propertyPath + "." + subPropertyName;
}
@@ -204,10 +237,10 @@
public PathedPropertyReferenceSource handleIntermediatePathPart(Ident name) {
Join join = locateOrBuildPropertyJoin( lhs, lhsPropertyName, null, false, false );
- return determineAppropriateIntermediateSourceType( join.getRhs(), name );
+ return determineAppropriateIntermediateSourceType( join.locateRhs(), name );
}
- public PropertyReference handleTerminalPathPart(Ident name) {
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
final EntityType type = ( EntityType ) lhs.getPropertyType( lhsPropertyName );
if ( isReferenceToPrimaryKey( type, lhsPropertyName ) ) {
return generatePropertyReference( lhs, lhsPropertyName + "." + name.getText() );
@@ -217,12 +250,27 @@
final String propertyName = name.getText();
if ( type.isEntityType() ) {
if ( shouldTerminalEntityPropertyForceJoin() ) {
- locateOrBuildPropertyJoin( join.getRhs(), propertyName, null, false, false );
+ locateOrBuildPropertyJoin( join.locateRhs(), propertyName, null, false, false );
}
}
- return generatePropertyReference( join.getRhs(), propertyName );
+ return generatePropertyReference( join.locateRhs(), propertyName );
}
}
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ Join join = normalizationContext().getPropertyJoinBuilder().buildIndexOperationJoin(
+ lhs,
+ name.getText(),
+ null,
+ buildJoinTypeNode(),
+ selector
+ );
+ return new IndexAccessIntermediatePathSource( join.locateRhs() );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ return super.handleTerminalIndexAccess( lhs, name, selector );
+ }
}
protected boolean shouldTerminalEntityPropertyForceJoin() {
@@ -242,14 +290,51 @@
throw new HibernateException( "cannot implicit join across a collection association" );
}
- public PropertyReference handleTerminalPathPart(Ident name) {
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
// TODO : what are the circusmstances under which we need to *join* to the collection, as opposed to say munge it into a subquery???
final String nameText = name.getText();
if ( CollectionProperties.isAnyCollectionProperty( nameText ) ) {
Join join = locateOrBuildPropertyJoin( lhs, propertyName, null, false, false );
- return generatePropertyReference( join.getRhs(), nameText );
+ return generatePropertyReference( join.locateRhs(), nameText );
}
throw new HibernateException( "cannot implicit join across a collection association" );
}
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ throw new HibernateException( "cannot implicit join across a collection association" );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ throw new HibernateException( "cannot implicit join across a collection association" );
+ }
}
+
+ protected class IndexAccessIntermediatePathSource extends AbstractPathedPropertyReferenceSource {
+ private final IndexedCollectionElementAccessPersisterReference persisterReference;
+
+ public IndexAccessIntermediatePathSource(PersisterReference persisterReference) {
+ if ( persisterReference instanceof IndexedCollectionElementAccessPersisterReference ) {
+ this.persisterReference = ( IndexedCollectionElementAccessPersisterReference ) persisterReference;
+ }
+ else {
+ throw new HibernateException( "Expecting IndexedCollectionElementAccessPersisterReference, found " + persisterReference.getClass().getName() );
+ }
+ }
+
+ public PathedPropertyReferenceSource handleIntermediatePathPart(Ident name) {
+ return determineAppropriateIntermediateSourceType( persisterReference, name );
+ }
+
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
+ return generatePropertyReference( persisterReference, name.getText() );
+ }
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ throw new IllegalStateException( "doubled up index operators" );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ throw new IllegalStateException( "doubled up index operators" );
+ }
+ }
}
\ No newline at end of file
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/FromClausePathNormalizationStrategy.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/FromClausePathNormalizationStrategy.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/FromClausePathNormalizationStrategy.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -23,17 +23,18 @@
*/
package org.hibernate.sql.ast.phase.hql.normalize.path.impl;
-import antlr.collections.AST;
-
import org.hibernate.sql.ast.phase.hql.normalize.PersisterReference;
import org.hibernate.sql.ast.phase.hql.normalize.PropertyReference;
import org.hibernate.sql.ast.phase.hql.normalize.Ident;
import org.hibernate.sql.ast.phase.hql.normalize.NormalizationContext;
import org.hibernate.sql.ast.phase.hql.normalize.HqlNormalizeTokenTypes;
-import org.hibernate.sql.ast.phase.hql.normalize.path.AbstractPathNormalizationStrategy;
+import org.hibernate.sql.ast.phase.hql.normalize.PropertyPathTerminus;
+import org.hibernate.sql.ast.phase.hql.normalize.Join;
+import org.hibernate.sql.ast.phase.hql.normalize.path.impl.AbstractPathNormalizationStrategy;
import org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy;
import org.hibernate.sql.ast.phase.hql.normalize.path.PathedPropertyReferenceSource;
import org.hibernate.sql.ast.common.JoinType;
+import org.hibernate.sql.ast.common.Node;
import org.hibernate.type.Type;
import org.hibernate.HibernateException;
import org.hibernate.QueryException;
@@ -80,6 +81,18 @@
return new SourceImpl( persisterReference );
}
+ protected Join buildPropertyJoin(
+ PersisterReference lhs,
+ String propertyName,
+ String alias,
+ boolean propertyFetching,
+ boolean associationFetching) {
+ Join join = super.buildPropertyJoin( lhs, propertyName, alias, propertyFetching, associationFetching );
+ normalizationContext().getCurrentPersisterReferenceContext()
+ .registerPersisterReferenceImplicitInDerivedSelectClause( join.locateRhs() );
+ return join;
+ }
+
private class SourceImpl extends AbstractPathedPropertyReferenceSource {
private final PersisterReference lhs;
@@ -89,10 +102,10 @@
public PathedPropertyReferenceSource handleIntermediatePathPart(Ident name) {
// TODO : still need to account for paths including component dereferences...
- return new SourceImpl( locateOrBuildPropertyJoin( lhs, name.getText(), null, false, associationFetch ).getRhs() );
+ return new SourceImpl( locateOrBuildPropertyJoin( lhs, name.getText(), null, false, associationFetch ).locateRhs() );
}
- public PropertyReference handleTerminalPathPart(Ident name) {
+ public PropertyPathTerminus handleTerminalPathPart(Ident name) {
final String propertyName = name.getText();
Type terminalPropertyType = lhs.getPropertyType( propertyName );
if ( !terminalPropertyType.isAssociationType() ) {
@@ -106,9 +119,17 @@
return propertyReference;
}
+
+ public PathedPropertyReferenceSource handleIntermediateIndexAccess(Ident name, Node selector) {
+ throw new UnsupportedOperationException( "index operation not supported in from clause" );
+ }
+
+ public PropertyPathTerminus handleTerminalIndexAccess(Ident name, Node selector) {
+ throw new UnsupportedOperationException( "index operation not supported in from clause" );
+ }
}
- protected AST buildJoinTypeNode() {
+ protected Node buildJoinTypeNode() {
if ( joinType == JoinType.INNER ) {
return createNode( INNER, "inner" );
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/SelectClausePathNormalizationStrategy.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/SelectClausePathNormalizationStrategy.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/SelectClausePathNormalizationStrategy.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -41,6 +41,6 @@
protected boolean shouldTerminalEntityPropertyForceJoin() {
// here we should *as long as* we are not part of a function processing
- return ! getNormalizationContext().isCurrentlyProcessingFunction();
+ return ! normalizationContext().isCurrentlyProcessingFunction();
}
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/WithFragmentPathNormalizationStrategy.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/WithFragmentPathNormalizationStrategy.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/normalize/path/impl/WithFragmentPathNormalizationStrategy.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -23,9 +23,6 @@
*/
package org.hibernate.sql.ast.phase.hql.normalize.path.impl;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.hibernate.sql.ast.phase.hql.normalize.PersisterReference;
import org.hibernate.sql.ast.phase.hql.normalize.NormalizationContext;
import org.hibernate.sql.ast.phase.hql.normalize.Join;
@@ -33,6 +30,8 @@
import org.hibernate.QueryException;
import antlr.collections.AST;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* {@link org.hibernate.sql.ast.phase.hql.normalize.path.PathNormalizationStrategy} for dealing with <tt>WITH</tt>
@@ -41,7 +40,7 @@
* @author Steve Ebersole
*/
public class WithFragmentPathNormalizationStrategy extends BasicPathNormalizationStrategySupport {
- public static final Log log = LogFactory.getLog( WithFragmentPathNormalizationStrategy.class );
+ private static final Logger log = LoggerFactory.getLogger( WithFragmentPathNormalizationStrategy.class );
private final PersisterReference lhs;
@@ -57,7 +56,7 @@
AST nextPossible = lhs.getFirstChild();
while ( nextPossible != null ) {
if ( nextPossible instanceof Join ) {
- if ( ( ( Join ) nextPossible ).getRhs() == rhs ) {
+ if ( ( ( Join ) nextPossible ).locateRhs() == rhs ) {
join = ( Join ) nextPossible;
break;
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/HqlParser.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/HqlParser.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/HqlParser.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -25,8 +25,8 @@
import org.hibernate.sql.ast.util.ASTUtil;
import org.hibernate.sql.ast.util.ASTPrinter;
-import org.hibernate.sql.ast.util.ErrorCounter;
-import org.hibernate.sql.ast.util.ParseErrorHandler;
+import org.hibernate.sql.ast.util.ErrorHandlerDelegateImpl;
+import org.hibernate.sql.ast.util.ErrorHandlerDelegate;
import org.hibernate.QueryException;
import org.hibernate.MappingException;
import org.hibernate.persister.entity.EntityPersister;
@@ -65,7 +65,7 @@
private static final Logger log = LoggerFactory.getLogger( HqlParser.class );
private final Context context;
- private final ParseErrorHandler parseErrorHandler = new ErrorCounter();
+ private final ErrorHandlerDelegate parseErrorHandler = new ErrorHandlerDelegateImpl();
private final ASTPrinter printer = new ASTPrinter( HqlParseTokenTypes.class );
private int traceDepth = 0;
@@ -93,7 +93,7 @@
parseErrorHandler.reportWarning( s );
}
- public ParseErrorHandler getParseErrorHandler() {
+ public ErrorHandlerDelegate getParseErrorHandler() {
return parseErrorHandler;
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/PathCollector.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/PathCollector.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/phase/hql/parse/PathCollector.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -40,22 +40,23 @@
}
public static String getPath(AST dotStructure) {
- if ( dotStructure.getType() == IDENT ) {
+ if ( dotStructure.getType() == DOT ) {
+ return extractText( dotStructure );
+ }
+ else {
return dotStructure.getText();
}
-
- return extractText( dotStructure );
}
private static String extractText(AST node) {
AST lhs = node.getFirstChild();
AST rhs = lhs.getNextSibling();
- if ( lhs.getType() == IDENT ) {
- return lhs.getText() + node.getText() + rhs.getText();
+ if ( lhs.getType() == DOT ) {
+ return extractText( lhs ) + node.getText() + rhs.getText();
}
else {
- return extractText( lhs ) + node.getText() + rhs.getText();
+ return lhs.getText() + node.getText() + rhs.getText();
}
}
}
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTPrinter.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTPrinter.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTPrinter.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -131,10 +131,15 @@
* or just the integer as a string if none exists.
*/
public String getTokenTypeName(int type) {
- if ( tokenTypeNameCache == null ) {
- return Integer.toString( type );
+ final Integer typeInteger = new Integer( type );
+ String value = null;
+ if ( tokenTypeNameCache != null ) {
+ value = ( String ) tokenTypeNameCache.get( typeInteger );
}
- return ( String ) tokenTypeNameCache.get( new Integer( type ) );
+ if ( value == null ) {
+ value = typeInteger.toString();
+ }
+ return value;
}
private void showAst(ArrayList parents, PrintWriter pw, AST ast) {
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTUtil.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTUtil.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ASTUtil.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -383,14 +383,31 @@
* @param value The value of the constant.
*
* @return The token type name, *or* the integer value if the name could not be found.
+ *
+ * @deprecated Use #getTokenTypeName instead
*/
public static String getConstantName(Class owner, int value) {
- String tokenTypeName = Integer.toString( value );
- if ( owner != null ) {
- Field[] fields = owner.getFields();
+ return getTokenTypeName( owner, value );
+ }
+
+ /**
+ * Intended to retrieve the name of an AST token type based on the token type interface. However, this
+ * method can be used to look up the name of any constant defined on a class/interface based on the constant value.
+ * Note that if multiple constants have this value, the first will be returned which is known to be different
+ * on different JVM implementations.
+ *
+ * @param tokenTypeInterface The *TokenTypes interface (or one of its implementors).
+ * @param tokenType The token type value.
+ *
+ * @return The corresponding name.
+ */
+ public static String getTokenTypeName(Class tokenTypeInterface, int tokenType) {
+ String tokenTypeName = Integer.toString( tokenType );
+ if ( tokenTypeInterface != null ) {
+ Field[] fields = tokenTypeInterface.getFields();
for ( int i = 0; i < fields.length; i++ ) {
final Integer fieldValue = extractIntegerValue( fields[i] );
- if ( fieldValue != null && fieldValue.intValue() == value ) {
+ if ( fieldValue != null && fieldValue.intValue() == tokenType ) {
tokenTypeName = fields[i].getName();
break;
}
@@ -419,17 +436,4 @@
}
return rtn;
}
-
- /**
- * Just a friendly renaming of {@link #getConstantName}; in fact this method just simply delegates to that one.
- *
- * @param tokenTypeInterface The *TokenTypes interface (or one of its implementors).
- * @param tokenType The token type value.
- * @return The corresponding name.
- *
- * @see #getConstantName
- */
- public static String getTokenTypeName(Class tokenTypeInterface, int tokenType) {
- return getConstantName( tokenTypeInterface, tokenType );
- }
}
Deleted: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorCounter.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorCounter.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorCounter.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -1,95 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, 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.sql.ast.util;
-
-import antlr.RecognitionException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.QueryException;
-import org.hibernate.sql.ast.QuerySyntaxException;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * An error handler that counts parsing errors and warnings.
- */
-public class ErrorCounter implements ParseErrorHandler {
- private Log log = LogFactory.getLog( ErrorCounter.class );
-
- private List errorList = new ArrayList();
- private List warningList = new ArrayList();
- private List recognitionExceptions = new ArrayList();
-
- public void reportError(RecognitionException e) {
- String msg = e.toString();
- reportError( msg );
- recognitionExceptions.add( e );
- if ( log.isTraceEnabled() ) {
- log.trace( msg, e );
- }
- }
-
- public void reportError(String message) {
- log.error( message );
- errorList.add( message );
- }
-
- public void reportWarning(String message) {
- log.debug( message );
- warningList.add( message );
- }
-
- public int getErrorCount() {
- return errorList.size();
- }
-
- private String getErrorString() {
- StringBuffer buf = new StringBuffer();
- for ( Iterator iterator = errorList.iterator(); iterator.hasNext(); ) {
- buf.append( ( String ) iterator.next() );
- if ( iterator.hasNext() ) buf.append( "\n" );
-
- }
- return buf.toString();
- }
-
- public void throwQueryException() throws QueryException {
- if ( getErrorCount() > 0 ) {
- if ( recognitionExceptions.size() > 0 ) {
- throw QuerySyntaxException.convert( ( RecognitionException ) recognitionExceptions.get( 0 ) );
- }
- else {
- throw new QueryException( getErrorString() );
- }
- }
- else {
- // all clear
- if ( log.isDebugEnabled() ) {
- log.debug( "throwQueryException() : no errors" );
- }
- }
- }
-}
\ No newline at end of file
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorHandlerDelegateImpl.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorHandlerDelegateImpl.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorHandlerDelegateImpl.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -23,16 +23,17 @@
*/
package org.hibernate.sql.ast.util;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import antlr.RecognitionException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.hibernate.QueryException;
import org.hibernate.sql.ast.QuerySyntaxException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
/**
* An implementation of the {@link ErrorHandlerDelegate} contract.
*
@@ -40,7 +41,7 @@
* @author Steve Ebersole
*/
public class ErrorHandlerDelegateImpl implements ErrorHandlerDelegate {
- private static final Log log = LogFactory.getLog( ErrorHandlerDelegateImpl.class );
+ private static final Logger log = LoggerFactory.getLogger( ErrorHandlerDelegateImpl.class );
private List errorList = new ArrayList();
private List recognitionExceptions = new ArrayList();
Deleted: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorReporter.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorReporter.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ErrorReporter.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -1,39 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, 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.sql.ast.util;
-
-import antlr.RecognitionException;
-
-/**
- * Implementations will report or handle errors invoked by an ANTLR base parser.
- *
- * @author Joshua Davis
- */
-public interface ErrorReporter {
- void reportError(RecognitionException e);
-
- void reportError(String s);
-
- void reportWarning(String s);
-}
\ No newline at end of file
Deleted: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ParseErrorHandler.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ParseErrorHandler.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/ParseErrorHandler.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -1,39 +0,0 @@
-/*
- * Hibernate, Relational Persistence for Idiomatic Java
- *
- * Copyright (c) 2008, 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.sql.ast.util;
-
-import org.hibernate.QueryException;
-
-
-/**
- * Defines the behavior of an error handler for the Hibernate parsers.
- *
- * @author Joshua Davis
- */
-public interface ParseErrorHandler extends ErrorReporter {
-
- int getErrorCount();
-
- void throwQueryException() throws QueryException;
-}
\ No newline at end of file
Modified: core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/PathHelper.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/PathHelper.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/main/java/org/hibernate/sql/ast/util/PathHelper.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -28,10 +28,9 @@
import antlr.ASTFactory;
import antlr.collections.AST;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
/**
* Provides utility methods for dealing with path expressions.
* <p/>
@@ -41,7 +40,7 @@
* @author Steve Ebersole
*/
public final class PathHelper implements Sql92TokenTypes {
- private static final Log log = LogFactory.getLog( PathHelper.class );
+ private static final Logger log = LoggerFactory.getLogger( PathHelper.class );
/**
* Direct instantiation of PathHelper disallowed.
Modified: core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizerTest.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizerTest.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/normalize/NormalizerTest.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -34,10 +34,6 @@
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.sql.ast.util.NodeTraverser;
-import org.hibernate.sql.ast.phase.hql.normalize.HqlNormalizer;
-import org.hibernate.sql.ast.phase.hql.normalize.QuerySpec;
-import org.hibernate.sql.ast.phase.hql.normalize.SelectItem;
-import org.hibernate.sql.ast.phase.hql.normalize.SelectStatement;
import org.hibernate.sql.ast.phase.hql.parse.ParserTest;
import org.hibernate.sql.ast.phase.hql.domain.Animal;
import org.hibernate.sql.ast.common.JoinType;
@@ -72,7 +68,7 @@
}
public void testBasicStructure() throws Throwable {
- AST query = resolve( "select a from Animal a order by a.name" );
+ AST query = normalize( "select a from Animal a order by a.name" );
assertEquals( query.getType(), QUERY );
AST querySpec = query.getFirstChild();
@@ -99,26 +95,26 @@
public void testSimpleHql() throws Exception {
// First, get an AST by parsing some HQL text.
- AST ast = resolve( "from Animal" );
+ AST ast = normalize( "from Animal" );
// Assert:
assertEquals( ast.getType(), QUERY );
}
public void testSimpleExplicitJoins() throws Throwable {
- AST ast = resolve( "from Animal as a inner join a.mother as m" );
+ AST ast = normalize( "from Animal as a inner join a.mother as m" );
JoinCounter.assertJoinCount( 1, ast );
- ast = resolve( "from Animal as a inner join a.offspring as c inner join a.mother as m" );
+ ast = normalize( "from Animal as a inner join a.offspring as c inner join a.mother as m" );
JoinCounter.assertJoinCount( 2, ast );
}
public void testPathedExplicitJoins() throws Throwable {
- AST ast = resolve( "from Animal as a inner join a.mother.father.offspring as auntsanduncles" );
+ AST ast = normalize( "from Animal as a inner join a.mother.father.offspring as auntsanduncles" );
JoinCounter.assertJoinCount( 3, ast );
}
public void testSelectPersisterReference() throws Throwable {
- AST query = resolve( "select a from Animal a" );
+ AST query = normalize( "select a from Animal a" );
JoinCounter.assertJoinCount( 0, query );
SelectItemCounter.assertSelectItemCount( 1, query );
@@ -135,7 +131,7 @@
public void testSelectAssociationPropertyReference() throws Throwable {
// todo : implicit joins...
- AST query = resolve( "select a.mother as m from Animal as a" );
+ AST query = normalize( "select a.mother as m from Animal as a" );
JoinCounter.assertJoinCount( 1, query );
assertTrue( query instanceof SelectStatement );
@@ -148,7 +144,7 @@
Join join = ( Join ) itr.next();
assertFalse( itr.hasNext() );
assertEquals( JoinType.INNER, join.getEnumeratedJoinType() );
- PersisterReference rhs = join.getRhs();
+ PersisterReference rhs = join.locateRhs();
assertEquals( Animal.class.getName(), rhs.getName() );
// this should work since there is only one non-explicit persister alias...
assertEquals( "<gen:0>", rhs.getAlias() );
@@ -166,7 +162,7 @@
}
public void testSimpleSimplePropertyReference() throws Throwable {
- AST query = resolve( "select a.name as m from Animal as a" );
+ AST query = normalize( "select a.name as m from Animal as a" );
JoinCounter.assertJoinCount( 0, query );
SelectItemCounter.assertSelectItemCount( 1, query );
assertTrue( query instanceof SelectStatement );
@@ -187,7 +183,7 @@
}
public void testSelectPropertyRefCount() throws Throwable {
- AST query = resolve( "select count(a.mother) from Animal as a" );
+ AST query = normalize( "select count(a.mother) from Animal as a" );
JoinCounter.assertJoinCount( 0, query );
SelectItemCounter.assertSelectItemCount( 1, query );
assertTrue( query instanceof SelectStatement );
@@ -206,110 +202,135 @@
}
public void testExplicitImplicitJoin() throws Exception {
- AST ast = resolve( "from Animal a left join fetch a.mother.mother.mother as ggm where ggm.name like '%weeble%'" );
+ AST ast = normalize( "from Animal a left join fetch a.mother.mother.mother as ggm where ggm.name like '%weeble%'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 3, ast );
- ast = resolve( "from Animal as a inner join a.mother.mother as gm" );
+ ast = normalize( "from Animal as a inner join a.mother.mother as gm" );
JoinCounter.assertJoinCount( 2, ast );
- ast = resolve( "from Animal as a inner join a.mother.father as gf" );
+ ast = normalize( "from Animal as a inner join a.mother.father as gf" );
JoinCounter.assertJoinCount( 2, ast );
- ast = resolve( "from Animal as a inner join a.offspring as c inner join a.mother.father as mgf inner join fetch a.father" );
+ ast = normalize( "from Animal as a inner join a.offspring as c inner join a.mother.father as mgf inner join fetch a.father" );
JoinCounter.assertJoinCount( 4, ast );
}
public void testExplicitCollectionJoin() throws Throwable {
- AST ast = resolve( "from Animal as a inner join a.offspring as o where o.name like '%boots%'" );
+ normalize( "from Animal as a inner join a.offspring as o where o.name like '%boots%'" );
}
public void testSimpleImplicitJoin() throws Exception {
- AST ast = resolve( "from Animal a where a.mother.name like '%mary%'" );
+ AST ast = normalize( "from Animal a where a.mother.name like '%mary%'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 1, ast );
- ast = resolve( "from Animal a where a.mother.father.name like '%weeble%'" );
+ ast = normalize( "from Animal a where a.mother.father.name like '%weeble%'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 2, ast );
- ast = resolve( "from Animal a where a.mother.mother.name like '%weeble%'" );
+ ast = normalize( "from Animal a where a.mother.mother.name like '%weeble%'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 2, ast );
- ast = resolve( "from Animal a where a.mother.mother = ?" );
+ ast = normalize( "from Animal a where a.mother.mother = ?" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 1, ast );
}
public void testWithClause() throws Throwable {
- resolve( "from Zoo z inner join z.mammals as m with m.name = ?" );
+ normalize( "from Zoo z inner join z.mammals as m with m.name = ?" );
}
public void testUnqualifiedPropertyReference() throws Exception {
- AST ast = resolve( "from Animal where name like '%mary%'" );
+ AST ast = normalize( "from Animal where name like '%mary%'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 0, ast );
- ast = resolve( "from Animal where mother.name like '%mary%'" );
+ ast = normalize( "from Animal where mother.name like '%mary%'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 1, ast );
}
public void testThetaJoins() throws Exception {
- AST ast = resolve( "from Animal a, Animal b where a.mother.id = b.id and b.name like '%mary%'" );
+ AST ast = normalize( "from Animal a, Animal b where a.mother.id = b.id and b.name like '%mary%'" );
assertTrue( ast instanceof SelectStatement );
// JoinCounter.assertJoinCount( 1, ast );
- ast = resolve( "from Animal a, Animal b inner join b.mother as c where a.mother.id = b.id and b.name like '%mary%'" );
+ ast = normalize( "from Animal a, Animal b inner join b.mother as c where a.mother.id = b.id and b.name like '%mary%'" );
assertTrue( ast instanceof SelectStatement );
// JoinCounter.assertJoinCount( 2, ast );
}
public void testAdHocJoins() throws Exception {
- resolve( "from Animal a inner join Zoo z on a.id = z.id" );
- resolve( "from Animal a inner join Zoo z on a.id = z.id inner join z.mammals as m with m.name = ?" );
+ normalize( "from Animal a inner join Zoo z on a.id = z.id" );
+ normalize( "from Animal a inner join Zoo z on a.id = z.id inner join z.mammals as m with m.name = ?" );
}
public void testReusingImplcitJoins() throws Throwable {
- AST ast = resolve( "from Animal a where a.mother.father.name = 'abc' and a.mother.father.description = 'xyz'" );
+ AST ast = normalize( "from Animal a where a.mother.father.name = 'abc' and a.mother.father.description = 'xyz'" );
assertTrue( ast instanceof SelectStatement );
JoinCounter.assertJoinCount( 2, ast );
}
- public void testIndexOperations() throws Throwable {
-// resolve( "select o from IndexedCollectionOwner as o where o.simpleMap['test'] = 'xyz'" );
- resolve( "select o from IndexedCollectionOwner as o inner join o.simpleMap as s where o.simpleMap[ index(s) ] = 'xyz'" );
- }
+// these entities were not copied over...
+// public void testIndexOperations() throws Throwable {
+// normalize( "select o from IndexedCollectionOwner as o where o.simpleMap['test'] = 'xyz'" );
+// normalize( "select o from IndexedCollectionOwner as o inner join o.simpleMap as s where o.simpleMap[ index(s) ] = 'xyz'" );
+// }
public void testIndexOperations2() throws Throwable {
- resolve( "from Zoo zoo join zoo.animals an where zoo.mammals[ index(an) ] = an" );
- resolve( "from Zoo where mammals['dog'] = ?" );
- resolve( "from Zoo zoo where zoo.mammals['dog'].father.description like '%black%'" );
+ normalize( "select zoo from Zoo as zoo where zoo.mammals['dog'] = maxelement(zoo.mammals)" );
+ normalize( "select zoo from Zoo as zoo where zoo.mammals['dog'].description = 'abc'" );
+ normalize( "from Zoo zoo join zoo.animals an where zoo.mammals[ index(an) ] = an" );
+ normalize( "from Zoo where mammals['dog'] = ?" );
+ normalize( "from Zoo zoo where zoo.mammals['dog'].father.description like '%black%'" );
}
+ public void testFilters() throws Exception {
+ String role = Animal.class.getName() + ".offspring";
+ normalizeFilter( "", role );
+ normalizeFilter( "order by this.id", role );
+ normalizeFilter( "where this.name = ?", role );
+ }
+
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- private AST resolve(String hql) throws RecognitionException, TokenStreamException {
- // to be completely accurate, the incoming hql string should be run through
- // QuerySplitter as that is what happens prior to translation and results in
- // a different string to actually translate...
- String[] queries = QuerySplitter.concreteQueries( hql, getSessionFactoryImplementor() );
- assertEquals( "polymorhpic queries not allowed here", 1, queries.length );
- hql = queries[0];
+ private AST normalize(String hql) throws RecognitionException, TokenStreamException {
+ return normalize( hql, getSessionFactoryImplementor() );
+ }
- AST hqlAst = ParserTest.doParse( hql, false );
+ private AST normalizeFilter(String hql, String role) throws RecognitionException, TokenStreamException {
+ return normalizeFilter( hql, role, getSessionFactoryImplementor() );
+ }
- // Now, pass it though the resolver phase, which yeilds
- // a processed HQL AST.
- HqlNormalizer resolver = new HqlNormalizer( sessionFactory );
- resolver.statement( hqlAst );
- AST resolvedHql = resolver.getAST();
- System.out.println( resolver.getPrinter().showAsString( resolvedHql, "Resolved AST : " + resolvedHql.toStringTree() + "" ) );
- return resolvedHql;
+ public static AST normalize(String hql, SessionFactoryImplementor sessionFactory) throws TokenStreamException, RecognitionException {
+ AST hqlAst = ParserTest.parse( splitQuery( hql, sessionFactory ) );
+
+ HqlNormalizer normalizer = new HqlNormalizer( sessionFactory );
+ normalizer.statement( hqlAst );
+ AST normalizedAST = normalizer.getAST();
+ System.out.println( normalizer.getPrinter().showAsString( normalizedAST, "Normalized query AST" ) );
+ return normalizedAST;
}
+ public static AST normalizeFilter(String hql, String role, SessionFactoryImplementor sessionFactory) throws TokenStreamException, RecognitionException {
+ AST hqlAst = ParserTest.parseFilter( splitQuery( hql, sessionFactory ), role );
+
+ HqlNormalizer normalizer = new HqlNormalizer( sessionFactory );
+ normalizer.statement( hqlAst );
+ AST normalizedAST = normalizer.getAST();
+ System.out.println( normalizer.getPrinter().showAsString( normalizedAST, "Normalized filter AST" ) );
+ return normalizedAST;
+ }
+
+ private static String splitQuery(String hql, SessionFactoryImplementor sessionFactory) {
+ String[] queries = QuerySplitter.concreteQueries( hql, sessionFactory );
+ assertEquals( "polymorhpic queries not allowed here", 1, queries.length );
+ return queries[0];
+ }
+
protected SessionFactoryImplementor getSessionFactoryImplementor() {
return sessionFactory;
}
Modified: core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/parse/ParserTest.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/parse/ParserTest.java 2009-02-09 19:27:30 UTC (rev 15918)
+++ core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/parse/ParserTest.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -4,7 +4,6 @@
import org.hibernate.sql.ast.util.ASTIterator;
import org.hibernate.sql.ast.common.Node;
import org.hibernate.sql.ast.util.ASTPrinter;
-import org.hibernate.sql.ast.phase.hql.parse.HqlParser;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -1013,15 +1012,15 @@
}
public void testEmptyFilter() throws Exception {
- parseFilter( "" ); // Blank is a legitimate filter.
+ parseFilter( "", "Owner.collection" ); // Blank is a legitimate filter.
}
public void testOrderByFilter() throws Exception {
- parseFilter( "order by this.id" );
+ parseFilter( "order by this.id", "Owner.collection" );
}
public void testRestrictionFilter() throws Exception {
- parseFilter( "where this.name = ?" );
+ parseFilter( "where this.name = ?", "Owner.collection" );
}
public void testNoFrom() throws Exception {
@@ -1099,7 +1098,7 @@
parse("select distinct user.party from com.itf.iceclaims.domain.party.user.UserImpl user inner join user.party.$RelatedWorkgroups relatedWorkgroups where relatedWorkgroups.workgroup.id = :workgroup and relatedWorkgroups.effectiveTime.start <= :datesnow and relatedWorkgroups.effectiveTime.end > :dateenow ");
}
public void testLineAndColumnNumber() throws Exception {
- AST ast = doParse("from Foo f\nwhere f.name = 'fred'",false);
+ AST ast = parse("from Foo f\nwhere f.name = 'fred'" );
// Find some of the nodes and check line and column values.
ASTIterator iter = new ASTIterator(ast);
boolean foundFoo = false;
@@ -1131,30 +1130,27 @@
}
- private void parse(String input) throws RecognitionException, TokenStreamException {
- doParse( input, false );
+ public static AST parse(String input) throws RecognitionException, TokenStreamException {
+ HqlParser parser = buildHqlParser( input );
+ parser.statement();
+ return extractAST( parser );
}
- private void parseFilter(String input) throws TokenStreamException, RecognitionException {
- doParse( input, true );
+ public static AST parseFilter(String input, String collectionRole) throws TokenStreamException, RecognitionException {
+ HqlParser parser = buildHqlParser( input );
+ parser.filterStatement( collectionRole );
+ return extractAST( parser );
}
- public static AST doParse(String input, boolean isFilter) throws RecognitionException, TokenStreamException {
- System.out.println( "input: ->" + ASTPrinter.escapeMultibyteChars(input) + "<-" );
- HqlParser parser = buildHqlParser( input );
- if ( isFilter ) {
- parser.filterStatement();
- }
- else {
- parser.statement();
- }
+ private static AST extractAST(HqlParser parser) {
AST ast = parser.getAST();
- show( ast, "AST [" + ast.toStringTree() + "]" );
+ show( ast, "Parsed AST" );
assertEquals( "At least one error occurred during parsing!", 0, parser.getParseErrorHandler().getErrorCount() );
return ast;
}
private static HqlParser buildHqlParser(String hql) {
+ System.out.println( "input: ->" + ASTPrinter.escapeMultibyteChars( hql ) + "<-" );
return new HqlParser(
hql,
new HqlParser.Context() {
Added: core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/ResolverTest.java
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/ResolverTest.java (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/test/java/org/hibernate/sql/ast/phase/hql/resolve/ResolverTest.java 2009-02-09 19:32:49 UTC (rev 15919)
@@ -0,0 +1,117 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2009, 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.sql.ast.phase.hql.resolve;
+
+import junit.framework.TestCase;
+
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.HSQLDialect;
+import org.hibernate.sql.ast.util.ASTPrinter;
+import org.hibernate.sql.ast.util.NodeDeepCopier;
+import org.hibernate.sql.ast.phase.hql.domain.Animal;
+import org.hibernate.sql.ast.phase.hql.domain.Human;
+import org.hibernate.sql.ast.phase.hql.normalize.NormalizerTest;
+import org.hibernate.persister.entity.AbstractEntityPersister;
+
+import antlr.ASTFactory;
+import antlr.TokenStreamException;
+import antlr.RecognitionException;
+import antlr.collections.AST;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class ResolverTest extends TestCase {
+ private static ASTPrinter printer = new ASTPrinter( HqlResolveTokenTypes.class );
+ private SessionFactoryImplementor sessionFactory;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ sessionFactory = ( SessionFactoryImplementor ) new Configuration()
+ .setProperty( Environment.HBM2DDL_AUTO, "none" )
+ .setProperty( Environment.DIALECT, HSQLDialect.class.getName() )
+ .addResource( "org/hibernate/sql/ast/phase/hql/domain/Mappings.hbm.xml" )
+ .buildSessionFactory();
+ }
+
+ protected void tearDown() throws Exception {
+ if ( sessionFactory != null ) {
+ sessionFactory.close();
+ }
+ super.tearDown();
+ }
+
+ public void testResolve() throws Throwable {
+// resolve( "from Animal a" );
+// resolve( "select a.description from Animal a" );
+ resolve( "select a from Animal a" );
+ }
+
+ public void testFilters() throws Exception {
+ String role = Animal.class.getName() + ".offspring";
+ AST ast = resolveFilter( "", role );
+ resolveFilter( "order by this.id", role );
+ resolveFilter( "where this.name = ?", role );
+ }
+
+ public void testPropertyJoins() throws Throwable {
+ resolve( "from Animal a inner join a.father as f" );
+ }
+
+ public void testPersisterJoins() throws Throwable {
+// resolve( "from Animal a, Animal b" );
+ resolve( "from Animal a cross join Animal b" );
+// resolve( "from Animal a inner join Animal b on a.mother = b.father" );
+ }
+
+ private AST resolve(String hql) throws TokenStreamException, RecognitionException {
+ return resolve( hql, sessionFactory );
+ }
+
+ private AST resolveFilter(String hql, String role) throws TokenStreamException, RecognitionException {
+ return resolveFilter( hql, role, sessionFactory );
+ }
+
+ public static AST resolve(String hql, SessionFactoryImplementor sessionFactory) throws TokenStreamException, RecognitionException {
+ AST normalizedAST = NormalizerTest.normalize( hql, sessionFactory );
+ return resolve( normalizedAST, sessionFactory );
+ }
+
+ public static AST resolveFilter(String hql, String role, SessionFactoryImplementor sessionFactory) throws TokenStreamException, RecognitionException {
+ AST normalizedAST = NormalizerTest.normalizeFilter( hql, role, sessionFactory );
+ return resolve( normalizedAST, sessionFactory );
+ }
+
+ private static AST resolve(AST normalizedAST, SessionFactoryImplementor sessionFactory) throws RecognitionException {
+ HqlResolver resolver = new HqlResolver( sessionFactory );
+ resolver.statement( normalizedAST );
+ AST resolvedAST = resolver.getAST();
+ System.out.println( printer.showAsString( resolvedAST, "Resolved AST" ) );
+ return resolvedAST;
+ }
+}
15 years, 3 months
Hibernate SVN: r15918 - in validator/trunk: hibernate-validator and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-09 14:27:30 -0500 (Mon, 09 Feb 2009)
New Revision: 15918
Added:
validator/trunk/tck-utils/src/main/resources/META-INF/services/javax.annotation.processing.Processor
Removed:
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/HtmlTckReportGenerator.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/JSRReference.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessorFactory.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKReportGenerator.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java
validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
Modified:
validator/trunk/hibernate-validator-legacy/pom.xml
validator/trunk/hibernate-validator/pom.xml
validator/trunk/pom.xml
validator/trunk/tck-utils/pom.xml
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageReport.java
validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/SpecReference.java
validator/trunk/validation-api/pom.xml
Log:
switched tck-utils to use javax.annotations.processor
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/hibernate-validator/pom.xml 2009-02-09 19:27:30 UTC (rev 15918)
@@ -5,7 +5,7 @@
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>4.0.0.Alpha1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -138,4 +138,41 @@
</plugin>
</plugins>
</reporting>
+ <profiles>
+ <profile>
+ <id>tck-audit</id>
+ <activation>
+ <jdk>1.6</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ <executions>
+ <execution>
+ <id>run-annotation-processor-only</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal> testCompile</goal>
+ </goals>
+ <configuration>
+ <compilerArgument>-proc:only</compilerArgument>
+ <compilerArguments>
+ <s>foo</s>
+ <processor>org.hibernate.tck.report.CoverageProcessor</processor>
+ </compilerArguments>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Modified: validator/trunk/hibernate-validator-legacy/pom.xml
===================================================================
--- validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/hibernate-validator-legacy/pom.xml 2009-02-09 19:27:30 UTC (rev 15918)
@@ -5,7 +5,7 @@
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>4.0.0.Alpha1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>hibernate-validator-legacy</artifactId>
Modified: validator/trunk/pom.xml
===================================================================
--- validator/trunk/pom.xml 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/pom.xml 2009-02-09 19:27:30 UTC (rev 15918)
@@ -6,7 +6,7 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-parent</artifactId>
<packaging>pom</packaging>
- <version>1.0.0-SNAPSHOT</version>
+ <version>4.0.0.Alpha1-SNAPSHOT</version>
<name>Hibernate Validator Parent</name>
<url>http://localhost/~hardy/</url>
@@ -49,7 +49,6 @@
<module>validation-api</module>
<module>hibernate-validator</module>
<module>hibernate-validator-legacy</module>
- <module>tck-utils</module>
</modules>
<dependencyManagement>
@@ -57,13 +56,8 @@
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
- <version>${version}</version>
+ <version>1.0.Beta3-SNAPSHOT</version>
</dependency>
- <!--dependency>
- <groupId>com.google.code.guice</groupId>
- <artifactId>guice</artifactId>
- <version>1.0</version>
- </dependency-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
@@ -78,7 +72,7 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
- </dependency>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -165,7 +159,7 @@
<scm>
<connection>scm:https://svn.jboss.org/repos/hibernate/validator/trunk</connection>
- <url>http://fisheye.jboss.org/browse/Fixme</url>
+ <url>http://fisheye.jboss.org/browse/Hibernate/validator/trunk</url>
</scm>
<distributionManagement>
@@ -215,10 +209,10 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
</plugin>
- <!--plugin>
+ <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>changelog-maven-plugin</artifactId>
- </plugin-->
+ </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>changes-maven-plugin</artifactId>
Modified: validator/trunk/tck-utils/pom.xml
===================================================================
--- validator/trunk/tck-utils/pom.xml 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/pom.xml 2009-02-09 19:27:30 UTC (rev 15918)
@@ -67,16 +67,6 @@
<dependencies>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.4.2</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.4.2</version>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
@@ -117,6 +107,7 @@
<configuration>
<source>1.5</source>
<target>1.5</target>
+ <compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
Deleted: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/HtmlTckReportGenerator.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/HtmlTckReportGenerator.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/HtmlTckReportGenerator.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,94 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.tck;
-
-import java.util.List;
-
-/**
- * @author Hardy Ferentschik
- */
-public class HtmlTckReportGenerator implements TCKReportGenerator {
- private final String[] tableHeaders = new String[] { "Section", "Class", "Method", "Note" };
- private StringBuffer out;
-
- public String generateReport(List<JSRReference> references) {
- out = new StringBuffer();
- writeHeader();
- writeContents( references );
- writeFooter();
- return out.toString();
- }
-
- private void writeFooter() {
- out.append( "</body></html>" );
- }
-
- private void writeHeader() {
- out.append( "<html><head></head><body>" );
- }
-
- private void writeTableHeader() {
- out.append( "<table border=\"1\"><tr>" );
- for ( String s : tableHeaders ) {
- out.append( "<th>" ).append( s ).append( "</th>" );
- }
- out.append( "</tr>" );
- }
-
- private void writeTableFooter() {
- out.append( "</table>" );
- }
-
- private void writeContents(List<JSRReference> references) {
- writeTableHeader();
- String currentReference = "";
- boolean sameReference;
- String currentClass = "";
- for ( JSRReference reference : references ) {
- out.append( "<tr>" );
-
- if ( currentReference.equals( reference.jsrSectionReference ) ) {
- sameReference = true;
- out.append( "<td></td>" );
- }
- else {
- currentReference = reference.jsrSectionReference;
- sameReference = false;
- out.append( "<td>" ).append( reference.jsrSectionReference ).append( "</td>" );
- }
-
- if ( sameReference && currentClass.equals( reference.className ) ) {
- out.append( "<td></td>" );
- }
- else {
- currentClass = reference.className;
- out.append( "<td><a href=\"" )
- .append( reference.getSourceLink() )
- .append( "\">" )
- .append( reference.className )
- .append( "</a></td>" );
- }
-
- out.append( "<td>" ).append( reference.methodName ).append( "</td>" );
-
- out.append( "<td>" ).append( reference.note ).append( "</td>" );
- out.append( "</tr>" );
- }
- writeTableFooter();
- }
-}
Deleted: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/JSRReference.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/JSRReference.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/JSRReference.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,77 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.tck;
-
-/**
- * @author Hardy Ferentschik
- */
-public class JSRReference implements Comparable {
- /**
- * The JSR section this instance references.
- */
- String jsrSectionReference;
-
- /**
- * The name of the class which references the JSR.
- */
- String className;
-
- /**
- * The method which references the JSR.
- */
- String methodName;
-
- /**
- * Optional note specified on the specification reference
- */
- String note = "";
-
- JSRReference(String reference, String className, String methodName) {
- this.jsrSectionReference = reference;
- this.className = className;
- this.methodName = methodName;
- }
-
- public String getSourceLink() {
- StringBuilder builder = new StringBuilder();
- builder.append( "xref-test/" );
- builder.append( className.replace( '.', '/' ) );
- builder.append( ".html" );
- return builder.toString();
- }
-
- public String getJsrSectionReference() {
- return jsrSectionReference;
- }
-
- public String getClassName() {
- return className;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public String getNote() {
- return note;
- }
-
- public int compareTo(Object o) {
- return jsrSectionReference.compareTo( ( ( JSRReference ) o ).jsrSectionReference );
- }
-}
Deleted: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessor.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,105 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.tck;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Collections;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import static com.sun.mirror.util.DeclarationVisitors.NO_OP;
-import static com.sun.mirror.util.DeclarationVisitors.getDeclarationScanner;
-import com.sun.mirror.util.SimpleDeclarationVisitor;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-
-/**
- * An APT annotation processor for creating a TCK coverage report.
- *
- * @author Hardy Ferentschik
- */
-public class TCKAnnotationProcessor implements AnnotationProcessor {
-
- private static final String OUTDIR_OPTION_NAME = "-s";
- private static final String REPORT_FILE_NAME = "tck.html";
-
- private final AnnotationProcessorEnvironment env;
- private final List<JSRReference> references = new ArrayList<JSRReference>();
- private final File baseDir;
-
- public TCKAnnotationProcessor(AnnotationProcessorEnvironment annotationProcessorEnvironment) {
- this.env = annotationProcessorEnvironment;
- String baseDirName = env.getOptions().get( OUTDIR_OPTION_NAME );
- baseDir = new File( baseDirName );
- baseDir.mkdirs();
- }
-
- public void process() {
-
-
- AnnotationTypeDeclaration annType = ( AnnotationTypeDeclaration ) env.getTypeDeclaration(
- SpecAssertion.class.getCanonicalName()
- );
- for ( Declaration d : env.getDeclarationsAnnotatedWith( annType ) ) {
- d.accept(
- getDeclarationScanner(
- new CreateReferenceVisitor(),
- NO_OP
- )
- );
- }
-
- Collections.sort( references );
- TCKReportGenerator generator = new HtmlTckReportGenerator();
- String report = generator.generateReport( references );
- writeReportFile( report );
- }
-
- private void writeReportFile(String report) {
- try {
- File reportFile = new File( baseDir, REPORT_FILE_NAME );
- BufferedWriter writer = new BufferedWriter( new FileWriter( reportFile ) );
- writer.write( report );
- writer.close();
- }
- catch ( IOException e ) {
- System.err.println( "Error writing report." );
- }
- }
-
- private class CreateReferenceVisitor extends SimpleDeclarationVisitor {
- public void visitMethodDeclaration(MethodDeclaration d) {
- SpecAssertion annotation = d.getAnnotation( SpecAssertion.class );
- JSRReference ref = new JSRReference(
- annotation.section(), d.getDeclaringType().getQualifiedName(), d.getSimpleName()
- );
- if ( annotation.note().length() > 0 ) {
- ref.note = annotation.note();
- }
- references.add( ref );
- }
- }
-}
Deleted: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessorFactory.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessorFactory.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKAnnotationProcessorFactory.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,65 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.tck;
-
-import java.util.Arrays;
-import java.util.Collection;
-import static java.util.Collections.emptySet;
-import static java.util.Collections.unmodifiableCollection;
-import java.util.Set;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-import org.hibernate.tck.annotations.SpecVersion;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class TCKAnnotationProcessorFactory implements AnnotationProcessorFactory {
-
- // Process any set of annotations
- private static final Collection<String> supportedAnnotations
- = unmodifiableCollection(
- Arrays.asList(
- SpecAssertion.class.getCanonicalName(),
- SpecVersion.class.getCanonicalName()
- )
- );
-
- // No supported options
- private static final Collection<String> supportedOptions = emptySet();
-
-
- public Collection<String> supportedOptions() {
- return supportedOptions;
- }
-
- public Collection<String> supportedAnnotationTypes() {
- return supportedAnnotations;
- }
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> annotationTypeDeclarations, AnnotationProcessorEnvironment annotationProcessorEnvironment) {
- return new TCKAnnotationProcessor( annotationProcessorEnvironment );
-
- }
-}
Deleted: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKReportGenerator.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKReportGenerator.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/TCKReportGenerator.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,29 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-* http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.tck;
-
-import java.util.List;
-
-/**
- * @author Hardy Ferentschik
- */
-public interface TCKReportGenerator {
-
- public String generateReport(List<JSRReference> references);
-
-}
Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/annotations/SpecAssertions.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -20,11 +20,10 @@
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
+import java.lang.annotation.Annotation;
@Target(ElementType.METHOD)
@Documented
-public @interface SpecAssertions {
-
+public @interface SpecAssertions {
SpecAssertion[] value();
-
}
\ No newline at end of file
Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessor.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,139 +1,163 @@
package org.hibernate.tck.report;
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+
+import javax.annotation.processing.*;
+import static javax.lang.model.SourceVersion.RELEASE_6;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-import com.sun.mirror.declaration.Declaration;
-import com.sun.mirror.declaration.MethodDeclaration;
-import com.sun.mirror.util.DeclarationVisitors;
-import com.sun.mirror.util.SimpleDeclarationVisitor;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-import org.hibernate.tck.annotations.SpecAssertions;
-
/**
* Annotation processor for generating TCK coverage report
*
* @author Shane Bryzak
+ * @author Hardy Ferentschik
*/
-public class CoverageProcessor implements AnnotationProcessor {
- private static final String OUTDIR_OPTION_FLAG = "-s";
- private static final String AUDITFILE_OPTION_FLAG = "-a";
- private static final String REPORT_FILE_NAME = "coverage.html";
+@SupportedAnnotationTypes({
+ "org.hibernate.tck.annotations.SpecAssertion", "org.hibernate.tck.annotations.SpecAssertions"
+})
+@SupportedSourceVersion(RELEASE_6)
+public class CoverageProcessor extends AbstractProcessor {
+ private static final String OUTDIR_OPTION_FLAG = "-s";
+ private static final String AUDITFILE_OPTION_FLAG = "-a";
+ private static final String REPORT_FILE_NAME = "coverage.html";
- private static final String DEFAULT_AUDIT_FILE_NAME = "tck-audit.xml";
+ private static final String DEFAULT_AUDIT_FILE_NAME = "tck-audit.xml";
- private final AnnotationProcessorEnvironment env;
+ private final List<SpecReference> references = new ArrayList<SpecReference>();
- private final List<SpecReference> references = new ArrayList<SpecReference>();
+ private AuditParser auditParser;
- private AuditParser auditParser;
+ private File baseDir;
- private File baseDir;
+ public CoverageProcessor() {
+ }
- public CoverageProcessor(AnnotationProcessorEnvironment env) {
- this.env = env;
+ public void init(ProcessingEnvironment env) {
+ super.init(env);
- createOutputDir( env );
- InputStream in = getAuditFileInputStream( env );
+ createOutputDir();
+ InputStream in = getAuditFileInputStream();
- if ( in == null ) {
- return;
- }
+ if (in == null) {
+ return;
+ }
- try {
- auditParser = new AuditParser( in );
- auditParser.parse();
- }
- catch ( Exception e ) {
- throw new RuntimeException( "Unable to parse audit file." );
- }
- }
+ try {
+ auditParser = new AuditParser(in);
+ auditParser.parse();
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Unable to parse audit file.");
+ }
+ }
- private InputStream getAuditFileInputStream(AnnotationProcessorEnvironment env) {
- InputStream in;
- String auditFileName = env.getOptions().get( AUDITFILE_OPTION_FLAG );
- if ( auditFileName == null || auditFileName.length() == 0 ) {
- env.getMessager()
- .printNotice( "No audit file specified on the command line. Trying default: " + DEFAULT_AUDIT_FILE_NAME );
- auditFileName = DEFAULT_AUDIT_FILE_NAME;
- }
- try {
- in = new FileInputStream( auditFileName );
- }
- catch ( IOException ex ) {
- env.getMessager().printWarning( "Unable to open audit file - " + auditFileName );
- env.getMessager().printWarning( "No report generated" );
- return null;
- }
- return in;
- }
+ private InputStream getAuditFileInputStream() {
+ InputStream in;
+ String auditFileName = processingEnv.getOptions().get(AUDITFILE_OPTION_FLAG);
+ if (auditFileName == null || auditFileName.length() == 0) {
+ auditFileName = getCurrentWorkingDirectory() + DEFAULT_AUDIT_FILE_NAME;
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.NOTE,
+ "No audit file specified on the command line. Trying default: " + auditFileName
+ );
+ }
+ try {
+ in = new FileInputStream(auditFileName);
+ }
+ catch (IOException ex) {
+ processingEnv.getMessager()
+ .printMessage(Diagnostic.Kind.WARNING, "Unable to open audit file - " + auditFileName);
+ processingEnv.getMessager().printMessage(Diagnostic.Kind.WARNING, "No report generated");
+ return null;
+ }
+ return in;
+ }
- private void createOutputDir(AnnotationProcessorEnvironment env) {
- String baseDirName = env.getOptions().get( OUTDIR_OPTION_FLAG );
- baseDir = new File( baseDirName );
- baseDir.mkdirs();
- }
- public void process() {
- if ( auditParser == null ) {
- return;
- }
+ private void createOutputDir() {
+ String baseDirName = processingEnv.getOptions().get(OUTDIR_OPTION_FLAG);
- AnnotationTypeDeclaration annotationType = ( AnnotationTypeDeclaration )
- env.getTypeDeclaration( SpecAssertion.class.getCanonicalName() );
+ // I would like to get the baseDir as property, but it seems that the maven compiler plugin still has issues - http://jira.codehaus.org/browse/MCOMPILER-75
+ if (baseDirName == null) {
+ baseDirName = getCurrentWorkingDirectory() + "target";
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.NOTE,
+ "No output directory specided using " + baseDirName + "instead."
+ );
+ }
+ baseDir = new File(baseDirName);
+ baseDir.mkdirs();
+ }
- for ( Declaration d : env.getDeclarationsAnnotatedWith( annotationType ) ) {
- d.accept(
- DeclarationVisitors.getDeclarationScanner(
- new CreateReferenceVisitor(), DeclarationVisitors.NO_OP
- )
- );
- }
+ private String getCurrentWorkingDirectory() {
+ return System.getProperty("user.dir") + System.getProperty("file.separator");
+ }
- annotationType = ( AnnotationTypeDeclaration )
- env.getTypeDeclaration( SpecAssertions.class.getCanonicalName() );
- for ( Declaration d : env.getDeclarationsAnnotatedWith( annotationType ) ) {
- d.accept(
- DeclarationVisitors.getDeclarationScanner(
- new CreateReferenceVisitor(), DeclarationVisitors.NO_OP
- )
- );
- }
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnvironment) {
+ if (auditParser == null) {
+ return true;
+ }
- new CoverageReport( references, auditParser ).writeToFile( new File( baseDir, REPORT_FILE_NAME ) );
- }
+ for (TypeElement type : annotations) {
+ processAnnoatedMethods(roundEnvironment, type);
+ }
- private class CreateReferenceVisitor extends SimpleDeclarationVisitor {
- public void visitMethodDeclaration(MethodDeclaration d) {
- SpecAssertions assertions = d.getAnnotation( SpecAssertions.class );
- if ( assertions != null ) {
- for ( SpecAssertion assertion : assertions.value() ) {
- SpecReference ref = new SpecReference(
- assertion.section(), assertion.id(),
- d.getDeclaringType().getSimpleName(), d.getSimpleName()
- );
- references.add( ref );
- }
- }
+ if (roundEnvironment.processingOver()) {
+ new CoverageReport(references, auditParser).writeToFile(new File(baseDir, REPORT_FILE_NAME));
+ }
+ return true;
+ }
- SpecAssertion assertion = d.getAnnotation( SpecAssertion.class );
- if ( assertion != null ) {
- SpecReference ref = new SpecReference(
- assertion.section(), assertion.id(),
- d.getDeclaringType().getSimpleName(), d.getSimpleName()
- );
- references.add( ref );
- }
- }
- }
+ private void processAnnoatedMethods(RoundEnvironment env, TypeElement annotation) {
+ Set<Element> elements = (Set<Element>) env.getElementsAnnotatedWith(annotation);
+ for (Element element : elements) {
+ processMethod(element);
+ }
+ }
+
+ private void processMethod(Element element) {
+ ExecutableElement methodElement = (ExecutableElement) element;
+ String annotationType = null;
+ for (AnnotationMirror annotationMirror : processingEnv.getElementUtils().getAllAnnotationMirrors(methodElement)) {
+ Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParameters =
+ processingEnv.getElementUtils().getElementValuesWithDefaults(annotationMirror);
+ annotationType = annotationMirror.getAnnotationType().toString();
+ if (annotationType.equals(SpecAssertions.class.getName())) {
+ List<AnnotationMirror> mirrors = (List<AnnotationMirror>) annotationMirror.getElementValues().values().iterator().next().getValue();
+ for (AnnotationMirror mirror : mirrors) {
+ createSpecReference(methodElement, processingEnv.getElementUtils().getElementValuesWithDefaults(mirror));
+ }
+ } else if (annotationType.equals(SpecAssertion.class.getName())) {
+ createSpecReference(methodElement, annotationParameters);
+ }
+ }
+ }
+
+ private void createSpecReference(ExecutableElement methodElement, Map<? extends ExecutableElement, ? extends AnnotationValue> annotationParameters) {
+ SpecReference ref = new SpecReference();
+ ref.setClassName(methodElement.getClass().getName());
+ ref.setMethodName(methodElement.getSimpleName().toString());
+ for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotationParameters.entrySet()) {
+ final String elementKey = entry.getKey().toString();
+ // TODO - is there no better way of doing this?
+ if (elementKey.equals("section()")) {
+ ref.setSection(entry.getValue().toString());
+ } else if (elementKey.equals("id()")) {
+ ref.setAssertion(entry.getValue().toString());
+ }
+ }
+ references.add(ref);
+ }
}
Deleted: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageProcessorFactory.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1,41 +0,0 @@
-package org.hibernate.tck.report;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
-import org.hibernate.tck.annotations.SpecAssertion;
-import org.hibernate.tck.annotations.SpecAssertions;
-
-import com.sun.mirror.apt.AnnotationProcessor;
-import com.sun.mirror.apt.AnnotationProcessorEnvironment;
-import com.sun.mirror.apt.AnnotationProcessorFactory;
-import com.sun.mirror.declaration.AnnotationTypeDeclaration;
-
-public class CoverageProcessorFactory implements AnnotationProcessorFactory
-{
- private static final Collection<String> supportedAnnotations = Collections.unmodifiableCollection(
- Arrays.asList(
- SpecAssertion.class.getCanonicalName(),
- SpecAssertions.class.getCanonicalName()
- )
- );
-
- public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> annotationTypeDeclarations,
- AnnotationProcessorEnvironment env)
- {
- return new CoverageProcessor(env);
- }
-
- public Collection<String> supportedAnnotationTypes()
- {
- return supportedAnnotations;
- }
-
- public Collection<String> supportedOptions()
- {
- return null;
- }
-
-}
Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageReport.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/CoverageReport.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -5,249 +5,221 @@
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Generates the TCK spec coverage report
- *
+ *
* @author Shane Bryzak
*/
-public class CoverageReport
-{
- /*
+public class CoverageReport {
+ /*
* References to the spec assertions made by the tck tests
*/
- private final Map<String,List<SpecReference>> references;
-
- private AuditParser auditParser;
-
- public CoverageReport(List<SpecReference> references, AuditParser auditParser)
- {
- this.references = new HashMap<String,List<SpecReference>>();
-
- for (SpecReference ref : references)
- {
- if (!this.references.containsKey(ref.getSection()))
- {
- this.references.put(ref.getSection(), new ArrayList<SpecReference>());
- }
-
- this.references.get(ref.getSection()).add(ref);
- }
-
- this.auditParser = auditParser;
- }
-
- public void generate(OutputStream out) throws IOException
- {
- writeHeader(out);
- writeCoverage(out);
- writeUnmatched(out);
- writeFooter(out);
- }
-
- private void writeHeader(OutputStream out) throws IOException
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
- sb.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n");
- sb.append("\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
- sb.append("<html>\n");
- sb.append("<head><title>JSR-299 TCK Coverage Report</title>\n");
-
- sb.append("<style type=\"text/css\">\n");
- sb.append(" .code {\n");
- sb.append(" float: left;\n");
- sb.append(" font-weight: bold;\n");
- sb.append(" width: 50px;\n");
- sb.append(" margin-top: 0px;\n");
- sb.append(" height: 100%; }\n");
- sb.append(" .results {\n");
- sb.append(" margin-left: 50px; }\n");
- sb.append(" .description {\n");
- sb.append(" margin-top: 2px;\n");
- sb.append(" margin-bottom: 2px; }\n");
- sb.append(" .sectionHeader {\n");
- sb.append(" font-weight: bold; }\n");
- sb.append(" .noCoverage {\n");
- sb.append(" margin-top: 2px;\n");
- sb.append(" margin-bottom: 2px;\n");
- sb.append(" font-weight: bold;\n");
- sb.append(" font-style: italic;\n");
- sb.append(" color: #ff0000; }\n");
- sb.append(" .coverageHeader {\n");
- sb.append(" font-weight: bold;\n");
- sb.append(" text-decoration: underline;\n");
- sb.append(" margin-top: 2px;\n");
- sb.append(" margin-bottom: 2px; }\n");
- sb.append(" .pass {\n");
- sb.append(" background-color: #dfd; }\n");
- sb.append(" .fail {\n");
- sb.append(" background-color: #fdd; }\n");
-
- sb.append("</style>\n");
-
- sb.append("</head><body>");
- sb.append("<h1>JSR-299 TCK Coverage</h1>");
- sb.append("<h2>");
- sb.append(auditParser.getVersion());
- sb.append("</h2>\n");
-
- out.write(sb.toString().getBytes());
- }
-
- private void writeCoverage(OutputStream out) throws IOException
- {
- for (String sectionId : auditParser.getSectionIds())
- {
- out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " +
- auditParser.getSectionTitle(sectionId) + "</div>\n").getBytes());
-
- List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
-
- if (sectionAssertions != null && !sectionAssertions.isEmpty())
- {
- StringBuilder sb = new StringBuilder();
-
- for (AuditAssertion assertion : sectionAssertions)
- {
- List<SpecReference> coverage = getCoverageForAssertion(sectionId, assertion.getId());
-
- sb.append(" <div class=\"" + (coverage.isEmpty() ? "fail" : "pass") + "\">\n");
-
- sb.append(" <span class=\"code\">");
- sb.append(assertion.getId());
- sb.append(")");
- sb.append("</span>\n");
-
- sb.append(" <div class=\"results\">");
- sb.append("<p class=\"description\">");
- sb.append(assertion.getText());
- sb.append("</p>\n");
-
- sb.append(" <div class=\"coverage\">\n");
- sb.append(" <p class=\"coverageHeader\">Coverage</p>\n");
-
- if (coverage.isEmpty())
- {
- sb.append(" <p class=\"noCoverage\">No tests exist for this assertion</p>\n");
- }
- else
- {
- for (SpecReference ref : coverage)
- {
- sb.append(" <p>");
- sb.append(ref.getClassName());
- sb.append(".");
- sb.append(ref.getMethodName());
- sb.append("()");
- sb.append("</p>\n");
- }
- }
-
- sb.append(" </div>\n </div>\n</div>");
+ private final Map<String, List<SpecReference>> references;
+
+ private AuditParser auditParser;
+
+ public CoverageReport(List<SpecReference> references, AuditParser auditParser) {
+ this.references = new HashMap<String, List<SpecReference>>();
+
+ for (SpecReference ref : references) {
+ if (!this.references.containsKey(ref.getSection())) {
+ this.references.put(ref.getSection(), new ArrayList<SpecReference>());
}
-
- out.write(sb.toString().getBytes());
- }
- }
- }
-
- private void writeUnmatched(OutputStream out) throws IOException
- {
- List<SpecReference> unmatched = new ArrayList<SpecReference>();
-
- for (String sectionId : references.keySet())
- {
- for (SpecReference ref : references.get(sectionId))
- {
- if (!auditParser.hasAssertion(ref.getSection(), ref.getAssertion()))
- {
- unmatched.add(ref);
+
+ this.references.get(ref.getSection()).add(ref);
+ }
+
+ this.auditParser = auditParser;
+ }
+
+ public void generate(OutputStream out) throws IOException {
+ writeHeader(out);
+ writeCoverage(out);
+ writeUnmatched(out);
+ writeFooter(out);
+ }
+
+ private void writeHeader(OutputStream out) throws IOException {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
+ sb.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n");
+ sb.append("\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n");
+ sb.append("<html>\n");
+ sb.append("<head><title>JSR-299 TCK Coverage Report</title>\n");
+
+ sb.append("<style type=\"text/css\">\n");
+ sb.append(" .code {\n");
+ sb.append(" float: left;\n");
+ sb.append(" font-weight: bold;\n");
+ sb.append(" width: 50px;\n");
+ sb.append(" margin-top: 0px;\n");
+ sb.append(" height: 100%; }\n");
+ sb.append(" .results {\n");
+ sb.append(" margin-left: 50px; }\n");
+ sb.append(" .description {\n");
+ sb.append(" margin-top: 2px;\n");
+ sb.append(" margin-bottom: 2px; }\n");
+ sb.append(" .sectionHeader {\n");
+ sb.append(" font-weight: bold; }\n");
+ sb.append(" .noCoverage {\n");
+ sb.append(" margin-top: 2px;\n");
+ sb.append(" margin-bottom: 2px;\n");
+ sb.append(" font-weight: bold;\n");
+ sb.append(" font-style: italic;\n");
+ sb.append(" color: #ff0000; }\n");
+ sb.append(" .coverageHeader {\n");
+ sb.append(" font-weight: bold;\n");
+ sb.append(" text-decoration: underline;\n");
+ sb.append(" margin-top: 2px;\n");
+ sb.append(" margin-bottom: 2px; }\n");
+ sb.append(" .pass {\n");
+ sb.append(" background-color: #dfd; }\n");
+ sb.append(" .fail {\n");
+ sb.append(" background-color: #fdd; }\n");
+
+ sb.append("</style>\n");
+
+ sb.append("</head><body>");
+ sb.append("<h1>JSR-299 TCK Coverage</h1>");
+ sb.append("<h2>");
+ sb.append(auditParser.getVersion());
+ sb.append("</h2>\n");
+
+ out.write(sb.toString().getBytes());
+ }
+
+ private void writeCoverage(OutputStream out) throws IOException {
+ for (String sectionId : auditParser.getSectionIds()) {
+ out.write(("<div class=\"sectionHeader\">Section " + sectionId + " - " +
+ auditParser.getSectionTitle(sectionId) + "</div>\n").getBytes());
+
+ List<AuditAssertion> sectionAssertions = auditParser.getAssertionsForSection(sectionId);
+
+ if (sectionAssertions != null && !sectionAssertions.isEmpty()) {
+ StringBuilder sb = new StringBuilder();
+
+ for (AuditAssertion assertion : sectionAssertions) {
+ List<SpecReference> coverage = getCoverageForAssertion(sectionId, assertion.getId());
+
+ sb.append(" <div class=\"" + (coverage.isEmpty() ? "fail" : "pass") + "\">\n");
+
+ sb.append(" <span class=\"code\">");
+ sb.append(assertion.getId());
+ sb.append(")");
+ sb.append("</span>\n");
+
+ sb.append(" <div class=\"results\">");
+ sb.append("<p class=\"description\">");
+ sb.append(assertion.getText());
+ sb.append("</p>\n");
+
+ sb.append(" <div class=\"coverage\">\n");
+ sb.append(" <p class=\"coverageHeader\">Coverage</p>\n");
+
+ if (coverage.isEmpty()) {
+ sb.append(" <p class=\"noCoverage\">No tests exist for this assertion</p>\n");
+ } else {
+ for (SpecReference ref : coverage) {
+ sb.append(" <p>");
+ sb.append(ref.getClassName());
+ sb.append(".");
+ sb.append(ref.getMethodName());
+ sb.append("()");
+ sb.append("</p>\n");
+ }
+ }
+
+ sb.append(" </div>\n </div>\n</div>");
+ }
+
+ out.write(sb.toString().getBytes());
}
- }
- }
-
- if (unmatched.isEmpty()) return;
-
- StringBuilder sb = new StringBuilder();
-
- sb.append("<h3>Unmatched tests</h3>\n");
- sb.append(String.format("<p>The following %d tests do not match any known assertions:</p>",
- unmatched.size()));
-
- sb.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n");
- sb.append(" <tr><th>Section</th><th>Assertion</th><th>Test Class</th><th>Test Method</th></tr>\n");
-
- for (SpecReference ref : unmatched)
- {
- sb.append("<tr>");
-
- sb.append("<td>");
- sb.append(ref.getSection());
- sb.append("</td>");
+ }
+ }
- sb.append("<td>");
- sb.append(ref.getAssertion());
- sb.append("</td>");
-
- sb.append("<td>");
- sb.append(ref.getClassName());
- sb.append("</td>");
-
- sb.append("<td>");
- sb.append(ref.getMethodName());
- sb.append("()");
- sb.append("</td>");
-
- sb.append("</tr>");
- }
-
- sb.append("</table>");
-
- out.write(sb.toString().getBytes());
- }
-
- private List<SpecReference> getCoverageForAssertion(String sectionId, String assertionId)
- {
- List<SpecReference> refs = new ArrayList<SpecReference>();
-
- if (references.containsKey(sectionId))
- {
- for (SpecReference ref : references.get(sectionId))
- {
- if (ref.getAssertion().equals(assertionId))
- {
- refs.add(ref);
+ private void writeUnmatched(OutputStream out) throws IOException {
+ List<SpecReference> unmatched = new ArrayList<SpecReference>();
+
+ for (String sectionId : references.keySet()) {
+ for (SpecReference ref : references.get(sectionId)) {
+ if (!auditParser.hasAssertion(ref.getSection(), ref.getAssertion())) {
+ unmatched.add(ref);
+ }
}
- }
- }
-
- return refs;
- }
-
- private void writeFooter(OutputStream out) throws IOException
- {
- out.write("</table>".getBytes());
- out.write("</body></html>".getBytes());
- }
-
- public void writeToFile(File file)
- {
- try
- {
- FileOutputStream out = new FileOutputStream(file);
- generate(out);
- out.flush();
- out.close();
- }
- catch (IOException ex)
- {
- throw new RuntimeException("Error generating report file", ex);
- }
- }
+ }
+
+ if (unmatched.isEmpty()) return;
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("<h3>Unmatched tests</h3>\n");
+ sb.append(String.format("<p>The following %d tests do not match any known assertions:</p>",
+ unmatched.size()));
+
+ sb.append("<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n");
+ sb.append(" <tr><th>Section</th><th>Assertion</th><th>Test Class</th><th>Test Method</th></tr>\n");
+
+ for (SpecReference ref : unmatched) {
+ sb.append("<tr>");
+
+ sb.append("<td>");
+ sb.append(ref.getSection());
+ sb.append("</td>");
+
+ sb.append("<td>");
+ sb.append(ref.getAssertion());
+ sb.append("</td>");
+
+ sb.append("<td>");
+ sb.append(ref.getClassName());
+ sb.append("</td>");
+
+ sb.append("<td>");
+ sb.append(ref.getMethodName());
+ sb.append("()");
+ sb.append("</td>");
+
+ sb.append("</tr>");
+ }
+
+ sb.append("</table>");
+
+ out.write(sb.toString().getBytes());
+ }
+
+ private List<SpecReference> getCoverageForAssertion(String sectionId, String assertionId) {
+ List<SpecReference> refs = new ArrayList<SpecReference>();
+
+ if (references.containsKey(sectionId)) {
+ for (SpecReference ref : references.get(sectionId)) {
+ if (ref.getAssertion().equals(assertionId)) {
+ refs.add(ref);
+ }
+ }
+ }
+
+ return refs;
+ }
+
+ private void writeFooter(OutputStream out) throws IOException {
+ out.write("</table>".getBytes());
+ out.write("</body></html>".getBytes());
+ }
+
+ public void writeToFile(File file) {
+ try {
+ FileOutputStream out = new FileOutputStream(file);
+ generate(out);
+ out.flush();
+ out.close();
+ }
+ catch (IOException ex) {
+ throw new RuntimeException("Error generating report file", ex);
+ }
+ }
}
Modified: validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/SpecReference.java
===================================================================
--- validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/SpecReference.java 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/java/org/hibernate/tck/report/SpecReference.java 2009-02-09 19:27:30 UTC (rev 15918)
@@ -2,41 +2,44 @@
/**
* Represents the metadata for a single instance of @SpecAssertion
- *
+ *
* @author Shane Bryzak
*/
-public class SpecReference
-{
- private String section;
- private String assertion;
- private String className;
- private String methodName;
-
- SpecReference(String section, String assertion, String className, String methodName)
- {
- this.section = section;
- this.assertion = assertion;
- this.className = className;
- this.methodName = methodName;
- }
-
- public String getSection()
- {
- return section;
- }
-
- public String getAssertion()
- {
- return assertion;
- }
-
- public String getClassName()
- {
- return className;
- }
-
- public String getMethodName()
- {
- return methodName;
- }
+public class SpecReference {
+ private String section;
+ private String assertion;
+ private String className;
+ private String methodName;
+
+ public void setSection(String section) {
+ this.section = section;
+ }
+
+ public void setAssertion(String assertion) {
+ this.assertion = assertion;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+
+ public String getSection() {
+ return section;
+ }
+
+ public String getAssertion() {
+ return assertion;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
}
Deleted: validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory
===================================================================
--- validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/tck-utils/src/main/resources/META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory 2009-02-09 19:27:30 UTC (rev 15918)
@@ -1 +0,0 @@
-org.hibernate.tck.report.CoverageProcessorFactory
\ No newline at end of file
Added: validator/trunk/tck-utils/src/main/resources/META-INF/services/javax.annotation.processing.Processor
===================================================================
--- validator/trunk/tck-utils/src/main/resources/META-INF/services/javax.annotation.processing.Processor (rev 0)
+++ validator/trunk/tck-utils/src/main/resources/META-INF/services/javax.annotation.processing.Processor 2009-02-09 19:27:30 UTC (rev 15918)
@@ -0,0 +1 @@
+org.hibernate.tck.report.CoverageProcessor
\ No newline at end of file
Modified: validator/trunk/validation-api/pom.xml
===================================================================
--- validator/trunk/validation-api/pom.xml 2009-02-09 18:30:53 UTC (rev 15917)
+++ validator/trunk/validation-api/pom.xml 2009-02-09 19:27:30 UTC (rev 15918)
@@ -3,23 +3,99 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-validator-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
+
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
+ <version>1.0.Beta3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bean Validation API</name>
+
+ <description>
+ Bean Validation (JSR-303) API.
+ </description>
+
+ <developers>
+ <developer>
+ <name>Emmanuel Bernard</name>
+ <email>emmanuel(a)hibernate.org</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ <url>http://in.relation.to/Bloggers/Emmanuel</url>
+ </developer>
+ <developer>
+ <name>Hardy Ferentschik</name>
+ <email>hferents(a)redhat.com</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ <url>http://in.relation.to/Bloggers/Hardy</url>
+ </developer>
+ </developers>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-webdav</artifactId>
+ <version>1.0-beta-2</version>
+ </extension>
+ </extensions>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <issueManagement>
+ <system>JIRA</system>
+ <url>http://opensource.atlassian.com/projects/hibernate/browse/BVAL</url>
+ </issueManagement>
+
+ <inceptionYear>2007</inceptionYear>
+
+ <licenses>
+ <license>
+ <name>Apache License, Version 2.0</name>
+ <url>license.txt</url>
+ </license>
+ </licenses>
+
+ <scm>
+ <connection>scm:https://svn.jboss.org/repos/hibernate/validator/trunk/validation-api</connection>
+ <url>http://fisheye.jboss.org/browse/Hibernate/validator/trunk/validation-api</url>
+ </scm>
- <distributionManagement>
- <site>
- <id>site</id>
- <url>file:///Users/hardy/Sites/${artifactId}</url>
- </site>
- </distributionManagement>
</project>
15 years, 3 months
Hibernate SVN: r15917 - in core/branches/SQL_GEN_REDESIGN/src/main/antlr: sql and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-02-09 13:30:53 -0500 (Mon, 09 Feb 2009)
New Revision: 15917
Added:
core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g
Modified:
core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/normalize.g
core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/parse.g
core/branches/SQL_GEN_REDESIGN/src/main/antlr/sql/common.g
Log:
HHH-2407 : HQL translation rework ->
HHH-3687 : parse (phase1)
HHH-3688 : normalize (phase2)
Modified: core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/normalize.g
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/normalize.g 2009-02-09 11:19:30 UTC (rev 15916)
+++ core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/normalize.g 2009-02-09 18:30:53 UTC (rev 15917)
@@ -63,6 +63,10 @@
tokens {
PROPERTY_REF;
+ INDEXED_COLLECTION_ACCESS_PERSISTER_REF;
+ INDEXED_COLLECTION_ELEMENT_REF;
+ ASSOCIATION_NAME;
+ INDEX_VALUE_CORRELATION;
}
@@ -70,16 +74,27 @@
{
private static Logger log = LoggerFactory.getLogger( GeneratedHqlNormalizer.class );
+ private AST currentFromClause;
+
private int ordinalParamCount = 0;
+ private int statementDepth = 0;
+ protected final int getStatementDepth() {
+ return statementDepth;
+ }
+ protected final boolean isSubquery() {
+ return statementDepth > 1;
+ }
+
+
// persister reference related actions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected AST normalizeEntityName(AST node) throws SemanticException {
throw new UnsupportedOperationException( "must be overridden!" );
}
- protected AST normalizeAlias(AST node) {
+ protected final AST normalizeAlias(AST node) {
if ( node != null ) {
return node;
}
@@ -133,6 +148,10 @@
throw new UnsupportedOperationException( "must be overridden!" );
}
+ protected AST normalizeUnqualifiedPropertyReferenceSource(AST propertyName) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
protected AST normalizeIndexedRoot(AST alias) {
throw new UnsupportedOperationException( "must be overridden!" );
}
@@ -145,103 +164,109 @@
throw new UnsupportedOperationException( "must be overridden!" );
}
+ protected AST normalizeIntermediateIndexOperation(AST collectionPath, AST selector) throws SemanticException {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
- // Statement node BEGIN/END handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ protected AST normalizeTerminalIndexOperation(AST collectionPath, AST selector) throws SemanticException {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+ protected void applyWithFragment(AST withFragment) {
+ }
+
+
+ // Statement node BEGIN/END handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
protected void pushStatement(AST statementNode) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void popStatement() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
- // property-path context pushing/popping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ // property-path context pushing/popping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void pushFromClausePropertyPathContext(AST joinType, AST fetch, AST alias, AST propertyFetch) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void popFromClausePropertyPathContext() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void pushSelectClausePropertyPathContext() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void popSelectClausePropertyPathContext() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void pushOnFragmentPropertyPathContext(AST rhsPersisterReference) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
- protected void popOnFragmentPropertyPathContext() {
+ protected AST popOnFragmentPropertyPathContext() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void pushWithFragmentPropertyPathContext(AST rhsPersisterReference) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void popWithFragmentPropertyPathContext() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
-
-
// function processing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void startingFunction() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
protected void endingFunction() {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
-
-
protected void registerSelectItem(AST selectItem) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
+ private void startQuerySpec(AST querySpecIn) {
+ statementDepth++;
+ applyCollectionFilter(querySpecIn);
+ }
+ private void endQuerySpec(AST querySpec) {
+ postProcessQuery( querySpec );
+ --statementDepth;
+ }
-
-
- protected AST resolveAlias(AST alias) {
- return alias;
- }
-
- /**
- * Validate the operands to the index operator '[]'. Specifically, the left-hand operand should be a reference
- * to some form of indexed collection (map or list) and the right-hand operand should be a value expression
- * whose type is the same as the indexed collection's index values.
- *
- * @param collectionPropertyReference The left-hand operand. Should resolve to an indexed collection
- * @param selector the right-hand operand. Should resolve to a value type compatible with the collection's
- * index type.
- */
- protected void validateIndexOperationOperands(AST collectionPropertyReference, AST selector) {
+ protected void applyCollectionFilter(AST querySpecIn) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
-
- // persister reference handling ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- protected AST buildEntityPersisterReference(AST entityName, AST alias, AST propertyFetch) {
- return entityName;
- }
-
- protected AST buildAdHocJoinNode(AST persisterReference, AST joinType, AST withFragment) {
- return persisterReference;
- }
-
- protected void applyWithFragment(AST withFragment) {
- }
-
- protected void injectSelectAlias( AST selectExpression, AST alias) {
+ protected void postProcessQuery(AST query) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
- protected void registerSelectExpression(AST selectExpression) {
+ protected AST buildRootEntityPersisterReference(AST persisterReferenceNode, AST entityName, AST alias, AST filter, AST propertyFetch) {
+ AST rtn = #( persisterReferenceNode, entityName, alias, filter );
+ registerPersisterReference( rtn );
+ if ( propertyFetch != null ) {
+ registerPropertyFetchNode( rtn );
+ }
+ return rtn;
}
- protected AST handleSelectedPropertyRef(AST propertyRef) {
- return propertyRef;
+ protected void registerPropertyFetchNode(AST persisterReference) {
+ throw new UnsupportedOperationException( "must be overridden!" );
}
-
}
// Statement rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -311,9 +336,9 @@
*/
insertStatement :
#(
- INSERT { pushStatement( #insertStatement ); }
- intoClause
- queryExpression { popStatement(); }
+ i:INSERT { pushStatement( #insertStatement ); }
+ ic:intoClause
+ qe:queryExpression { popStatement(); }
)
;
@@ -373,51 +398,52 @@
queryExpression
;
-querySpec :
- #( QUERY_SPEC selectFrom ( whereClause )? ( groupByClause ( havingClause )? )? )
+querySpec { startQuerySpec(#querySpec_in); } :
+ #( QUERY_SPEC selectFrom ( whereClause )? ( groupByClause ( havingClause )? )? ) { endQuerySpec(#querySpec); }
;
selectFrom :
- #( SELECT_FROM fromClause (selectClause)? )
+ #( SELECT_FROM fromClause (sc:selectClause)? )
;
// table/persister related rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-fromClause :
- #( FROM (persisterSpace)+ )
+fromClause! :
+ #( f:FROM {currentFromClause=#f;} (persisterSpace)+ {currentFromClause=null;} ) {
+ #fromClause = #f;
+ }
;
-persisterSpace :
- #( PERSISTER_SPACE entityPersisterReference ( explicitJoin )* )
+persisterSpace! :
+ #( PERSISTER_SPACE pr:entityPersisterReference {currentFromClause.addChild( #pr );} ( explicitPersisterJoin | explicitPropertyJoin )* )
;
entityPersisterReference! :
- #( epr:ENTITY_PERSISTER_REF en:ENTITY_NAME (a:ALIAS)? (pf:PROP_FETCH)? ) {
-// #entityPersisterReference = buildEntityPersisterReference( en, a, pf );
- AST entityName = normalizeEntityName( #en );
- AST alias = normalizeAlias( #a );
- #entityPersisterReference = #( #epr, entityName, alias, #pf );
- registerPersisterReference( #entityPersisterReference );
+ #( epr:ENTITY_PERSISTER_REF en:ENTITY_NAME a:ALIAS (f:FILTER)? (pf:PROP_FETCH)? ) {
+ #entityPersisterReference = buildRootEntityPersisterReference(
+ #epr,
+ normalizeEntityName( #en ),
+ normalizeAlias( #a ),
+ #f,
+ #pf
+ );
}
;
-explicitJoin :
- explicitPersisterJoin
- | explicitPropertyJoin
-;
-
-explicitPersisterJoin :
+explicitPersisterJoin!:
#(
j:PERSISTER_JOIN (
- CROSS entityPersisterReference
- | qualifiedJoinType e:entityPersisterReference (on:onFragment[#e])?
+ CROSS cjpr:entityPersisterReference {
+ currentFromClause.addChild( #cjpr );
+ }
+ | jt:qualifiedJoinType rhs:entityPersisterReference {pushOnFragmentPropertyPathContext(#rhs);} on:onFragment {
+ AST lhs = popOnFragmentPropertyPathContext();
+ lhs.addChild( #( #j, #jt, #rhs, #on ) );
+ }
)
- ) {
- #j.setType( JOIN );
- #j.setText( "join" );
- }
+ )
;
explicitPropertyJoin! :
@@ -429,10 +455,8 @@
| INNER
;
-onFragment[ AST rhsPersisterReference ] :
- #( o:ON { pushOnFragmentPropertyPathContext( rhsPersisterReference ); } sc:searchCondition ) {
- #onFragment = #( o, sc );
- }
+onFragment :
+ #( o:ON sc:searchCondition )
;
withFragment[ AST rhsPropertyReference ] :
@@ -927,7 +951,7 @@
propertyReference :
(unqualifiedPropertyReferenceCheck) => unqualifiedPropertyReference
| pathedPropertyReference
- | indexOperation
+ | terminalIndexOperation
;
/**
@@ -973,7 +997,7 @@
(persisterReferenceAliasCheck) => a:IDENT { #pathedPropertyReferenceSource = normalizeQualifiedRoot( #a ); }
| (unqualifiedPropertyReferenceCheck) => pr:IDENT { #pathedPropertyReferenceSource = normalizeUnqualifiedRoot( #pr ); }
| intermediatePathedPropertyReference
- | i:indexOperation { #pathedPropertyReferenceSource = normalizeIndexedRoot( #i ); }
+ | intermediateIndexOperation
;
/**
@@ -986,31 +1010,31 @@
alias:IDENT { isPersisterReferenceAlias( alias ) }?
;
-/**
- * AST construction rule for building AST relating to *known*
- * persister reference aliases. Do not call this rule unless
- * you know for certain (ala, have verified via the persisterReferenceAliasCheck
- * rule or similiar) that the next token is an IDENT representing an
- * alias for a persister reference
- */
-persisterReferenceAlias! :
- alias:IDENT {
- #persisterReferenceAlias = resolveAlias( alias );
- }
-;
-
intermediatePathedPropertyReference! :
#( d:DOT source:pathedPropertyReferenceSource prop:IDENT ) {
#intermediatePathedPropertyReference = normalizePropertyPathIntermediary( #source, #prop );
}
;
-indexOperation
- : #( i:INDEX_OP coll:collectionPropertyReference selector:indexSelector ) {
- validateIndexOperationOperands( #coll, #selector );
+intermediateIndexOperation! :
+ #( INDEX_OP collection:indexOperationSource selector:indexSelector ) {
+ #intermediateIndexOperation = normalizeIntermediateIndexOperation( #collection, #selector );
}
- ;
+;
+terminalIndexOperation! :
+ #( INDEX_OP collection:indexOperationSource selector:indexSelector ) {
+ #terminalIndexOperation = normalizeTerminalIndexOperation( #collection, #selector );
+ }
+;
+
+indexOperationSource :
+ #( DOT pathedPropertyReferenceSource IDENT )
+ | (unqualifiedPropertyReferenceCheck) => pr:IDENT {
+ #indexOperationSource = #( [DOT], normalizeUnqualifiedPropertyReferenceSource( #pr ), #pr );
+ }
+;
+
indexSelector
: valueExpression
// | literal
Modified: core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/parse.g
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/parse.g 2009-02-09 11:19:30 UTC (rev 15916)
+++ core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/parse.g 2009-02-09 18:30:53 UTC (rev 15917)
@@ -66,7 +66,7 @@
DYNAMIC_INSTANTIATION_ARG;
ENTITY_NAME;
ENTITY_PERSISTER_REF;
- FILTER_ENTITY;
+ FILTER;
GENERIC_FUNCTION;
INDEX_OP;
INSERTABILITY_SPEC;
@@ -258,9 +258,10 @@
// filter rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-filterStatement :
+filterStatement[String collectionRole] :
filteredSelectFrom (whereClause)? ( groupByClause ( havingClause )? )? (orderByClause)? {
- #filterStatement = #( [QUERY,"query"], #filterStatement );
+ AST querySpec = #( [QUERY_SPEC, "filter-query-spec"], [FILTER, collectionRole], #filterStatement );
+ #filterStatement = #( [QUERY,"query"], querySpec );
}
;
@@ -272,7 +273,7 @@
// Create an artificial token so the 'FROM' can be placed
// before the SELECT in the tree to make tree processing
// simpler.
- #filteredSelectFrom = #( [SELECT_FROM,"SELECT_FROM"], #f, #s );
+ #filteredSelectFrom = #( [SELECT_FROM,"select-from"], #f, #s );
}
;
@@ -372,7 +373,7 @@
*/
sortSpecification :
sortKey (collationSpecification)? (orderingSpecification)? {
- #sortSpecification = #( [SORT_SPEC, "{sort specification}"], #sortSpecification );
+ #sortSpecification = #( [SORT_SPEC, "sort-specification"], #sortSpecification );
}
;
@@ -427,7 +428,7 @@
// Create an artificial token so the 'FROM' can be placed
// before the SELECT in the tree to make tree processing
// simpler.
- #selectFrom = #( [SELECT_FROM,"SELECT_FROM"], f, s );
+ #selectFrom = #( [SELECT_FROM,"select-from"], f, s );
}
;
@@ -501,10 +502,10 @@
}
;
-crossJoin :
- CROSS j:JOIN^ {prepareForCrossJoinElements();} mainEntityPersisterReference {
- j.setType( PERSISTER_JOIN );
- j.setText( "persister-join" );
+crossJoin! :
+ c:CROSS j:JOIN {prepareForCrossJoinElements();} rhs:mainEntityPersisterReference {
+ #crossJoin = #( [PERSISTER_JOIN,"persister-join"], #c, rhs );
+ transferTrackingInfo( #j, #crossJoin );
}
;
Added: core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g (rev 0)
+++ core/branches/SQL_GEN_REDESIGN/src/main/antlr/hql/resolve.g 2009-02-09 18:30:53 UTC (rev 15917)
@@ -0,0 +1,854 @@
+header {
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, 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
+ *
+ * Portions of SQL grammar parsing copyright (C) 2003 by Lubos Vnuk. All rights
+ * reserved. These portions are distributed under license by Red Hat Middleware
+ * LLC and are covered by the above LGPL notice. If you redistribute this material,
+ * with or without modification, you must preserve this copyright notice in its
+ * entirety.
+ */
+package org.hibernate.sql.ast.phase.hql.resolve;
+
+import antlr.collections.AST;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.hibernate.sql.ast.DetailedSemanticException;
+}
+
+/**
+ * An Antlr tree parser for "resolving" an HQL AST. Essentially here we are concerned with creating a generic
+ * SQL AST.
+ *
+ * @author Joshua Davis
+ * @author Steve Ebersole
+ */
+class GeneratedHqlResolver extends TreeParser;
+
+options {
+ importVocab = HqlNormalize;
+ exportVocab = HqlResolve;
+ buildAST = true;
+}
+
+tokens {
+ COLUMN;
+ NAME;
+}
+
+
+{
+ private static Logger log = LoggerFactory.getLogger( GeneratedHqlResolver.class );
+
+ protected AST resolveEntityPersister(AST entityName, AST alias, AST filter) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected AST resolveCollectionPersister(AST collectionRole, AST alias) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void applyPropertyJoin(AST lhs, AST rhs, AST propertyName, AST joinType, AST with) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected AST generateIndexValueCondition(AST lhs, AST rhs, AST propertyName, AST selector ) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void appendSearchCondition(AST condition, AST container) {
+ if ( container.getFirstChild() == null ) {
+ container.setFirstChild( condition );
+ }
+ else {
+ AST and = #( [AND,"and"], container.getFirstChild() );
+ and.addChild( condition );
+ container.setFirstChild( and );
+ }
+ }
+
+ protected void applyVersionedUpdate(AST updateStatement) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void postProcessQuery(AST whereClause) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void startSelectClause() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void finishSelectClause() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void startFunction() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected void finishFunction() {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected AST resolvePropertyReference(AST persisterAlias, AST propertyName) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+
+ protected AST resolveAliasReference(AST aliasReference) {
+ throw new UnsupportedOperationException( "must be overridden!" );
+ }
+}
+
+
+// Statement rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+/**
+ * The main grammar rule
+ */
+statement :
+ updateStatement
+ | deleteStatement
+ | insertStatement
+ | selectStatement
+;
+
+
+// <tt>UPDATE</tt> statement ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+/**
+ * Recognize an <tt>UPDATE</tt> statement
+ */
+updateStatement :
+ #( u:UPDATE (v:VERSIONED)? en:ENTITY_NAME a:ALIAS setClause (whereClause)? ) {
+ if ( #v != null ) {
+ applyVersionedUpdate( #updateStatement );
+ }
+ }
+;
+
+setClause :
+ #( SET (assignment)+ )
+;
+
+assignment :
+ #( ASSIGNMENT_OP assignmentField newValue )
+;
+
+assignmentField :
+ propertyReference
+;
+
+newValue :
+ valueExpression
+;
+
+
+
+// <tt>DELETE</tt> statement ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+/**
+ * Recognize an HQL <tt>DELETE</tt> statement
+ */
+deleteStatement :
+ #( d:DELETE en:ENTITY_NAME a:ALIAS (whereClause)? )
+;
+
+
+// <tt>INSERT</tt> statement ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+/**
+ * Recognize an HQL <tt>INSERT</tt> statement
+ */
+insertStatement :
+ #( i:INSERT ic:intoClause qe:queryExpression )
+;
+
+intoClause :
+ #( INTO ENTITY_NAME insertabilitySpecification )
+;
+
+insertabilitySpecification :
+ #( INSERTABILITY_SPEC (insertablePropertySpecification)+ )
+;
+
+/**
+ * The property being inserted into.
+ */
+insertablePropertySpecification :
+ IDENT
+;
+
+
+// <tt>SELECT</tt> statement rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+/**
+ * Recognize an HQL <tt>SELECT</tt> statement.
+ * <p/>
+ * This corresponds most closely to the <cursor specification> rule in ISO/ANSI SQL...
+ */
+selectStatement :
+ #( QUERY queryExpression (orderByClause)? )
+;
+
+orderByClause :
+ #( ORDER_BY (sortSpecification)+ )
+;
+
+sortSpecification :
+ #( SORT_SPEC sortKey (collationSpecification)? (orderingSpecification)? )
+;
+
+sortKey :
+ // todo : do we want to explicitly limit these?
+ valueExpression
+;
+
+collationSpecification :
+ COLLATE
+;
+
+orderingSpecification :
+ ORDER_SPEC
+;
+
+queryExpression :
+ querySpec ( ( UNION | INTERSECT | EXCEPT ) (ALL)? querySpec )*
+;
+
+subquery :
+ queryExpression
+;
+
+querySpec! :
+ #( qs:QUERY_SPEC #(SELECT_FROM f:fromClause s:selectClause) (w:whereClause)? ( g:groupByClause ( h:havingClause )? )? ) {
+ #querySpec = #( #qs, #s, #f, #w, #g, #h );
+ postProcessQuery( #querySpec );
+ }
+;
+
+
+selectFrom :
+ #( SELECT_FROM fromClause selectClause )
+;
+
+
+// table/persister related rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+fromClause :
+ #( FROM (entityPersisterReference)+ )
+;
+
+persisterReference :
+ entityPersisterReference
+ | collectionPersisterReference
+ | indexedCollectionElementPersisterReference
+;
+
+entityPersisterReference! {
+ AST lhs = null;
+} :
+ #( epr:ENTITY_PERSISTER_REF en:ENTITY_NAME a:ALIAS (f:FILTER)? { lhs = resolveEntityPersister( #en, #a, #f ); } joins[lhs] ) {
+ #entityPersisterReference = lhs;
+ }
+;
+
+collectionPersisterReference! {
+ AST lhs = null;
+} :
+ #( COLLECTION_PERSISTER_REF cr:COLLECTION_ROLE a:ALIAS { lhs = resolveCollectionPersister( #cr, #a ); } joins[lhs] ) {
+ #collectionPersisterReference = lhs;
+ }
+;
+
+indexedCollectionElementPersisterReference! {
+ AST lhs = null;
+} :
+ #( INDEXED_COLLECTION_ACCESS_PERSISTER_REF cr:COLLECTION_ROLE a:ALIAS { lhs = resolveCollectionPersister( #cr, #a ); } indexSelector[lhs] joins[lhs] )
+;
+
+indexSelector[AST lhs] :
+ #( INDEX_VALUE_CORRELATION iv:selectedIndexValue )
+;
+
+selectedIndexValue! :
+ valueExpression
+;
+
+joins[AST lhs] :
+ ( persisterJoin[lhs] | propertyJoin[lhs] )*
+;
+
+persisterJoin![AST lhs] :
+ // NOTE : persister cross joins were mutated into root table references during normalize.
+ #( PERSISTER_JOIN jt:correlatedJoinType rhs:entityPersisterReference on:onFragment[lhs,rhs] ) {
+ lhs.addChild( #( [JOIN,"join"], #jt, #rhs, #on ) );
+ }
+;
+
+correlatedJoinType :
+ INNER
+ | LEFT
+ | RIGHT
+;
+
+onFragment[AST rhs, AST lhs] :
+ #( ON searchCondition )
+;
+
+propertyJoin![AST lhs] :
+ #( PROPERTY_JOIN jt:propertyJoinType pn:ASSOCIATION_NAME rhs:persisterReference (w:withFragment[lhs,#rhs])? ) {
+ applyPropertyJoin( lhs, #rhs, #pn, #jt, #w );
+ }
+;
+
+propertyJoinType:
+ INNER
+ | LEFT
+;
+
+
+withFragment[AST lhs, AST rhs] :
+ #( w:WITH searchCondition )
+;
+
+
+// select clause related rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+// todo : we need to tighten down exactly what is allowed in the select clause here...
+// todo : additionally certain nodes need to be interpretted differently when in select-clause versus other clauses:
+// think of an ALIAS_REF; in select-clause this should be expanded to the full columns list; elsewhere to just the pk/fk
+
+// actually may need something more like a strategy based on context...
+
+selectClause :
+ #( SELECT {startSelectClause();} (d:DISTINCT)? rootSelectExpression {finishSelectClause();} )
+;
+
+rootSelectExpression :
+ #( SELECT_LIST explicitSelectList )
+ | #( SELECT_ITEM rootDynamicInstantiation )
+;
+
+explicitSelectList :
+ ( explicitSelectItem )+
+;
+
+explicitSelectItem :
+ #( SELECT_ITEM selectExpression )
+;
+
+selectExpression :
+ valueExpression ( ALIAS )?
+;
+
+rootDynamicInstantiation :
+ #( DYNAMIC_INSTANTIATION dynamicInstantiationArguments )
+;
+
+nestedDynamicInstantiation :
+ #( DYNAMIC_INSTANTIATION dynamicInstantiationArguments (ALIAS)? )
+;
+
+dynamicInstantiationArguments :
+ ( dynamicInstantiationArgument )+
+;
+
+dynamicInstantiationArgument :
+ #( DYNAMIC_INSTANTIATION_ARG ( nestedDynamicInstantiation | selectExpression ) )
+;
+
+
+
+// where clause rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+whereClause :
+ #( WHERE searchCondition )
+;
+
+
+
+// group by clause rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+groupByClause :
+ #( GROUP_BY groupingSpecification )
+;
+
+groupingSpecification :
+ ( groupingValue )+
+;
+
+groupingValue :
+ valueExpression ( collationSpecification )?
+;
+
+
+
+// having clause related rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+havingClause :
+ #( HAVING searchCondition )
+;
+
+
+
+// value/expression recognition rules ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+numericValueExpression :
+ valueExpression
+;
+
+stringValueExpression :
+ characterValueExpression
+;
+
+characterValueExpression :
+ valueExpression
+;
+
+intervalValueExpression :
+ valueExpression
+;
+
+datetimeValueExpression :
+ valueExpression
+;
+
+valueExpression :
+ #( CONCATENATION_OP ARGLIST ( characterValueExpression )+ )
+ | #( UNARY_MINUS numericValueExpression )
+ | #( UNARY_PLUS numericValueExpression )
+ | #( PLUS_SIGN valueExpression valueExpression )
+ | #( MINUS_SIGN valueExpression valueExpression )
+ | #( ASTERISK numericValueExpression numericValueExpression )
+ | #( SOLIDUS numericValueExpression numericValueExpression )
+ | valueExpressionPrimary
+;
+
+valueExpressionPrimary :
+ persisterAliasReference
+ | caseExpression
+ | function
+ | collectionFunction
+ | collectionExpression
+ | literal
+ | parameter
+ | propertyReference
+;
+
+propertyReference! :
+ #( PROPERTY_REF a:ALIAS_REF pn:IDENT ) {
+ #propertyReference = resolvePropertyReference( #a, #pn );
+ }
+;
+
+nonCollectionPropertyReference :
+ pr:propertyReference
+;
+
+collectionPropertyReference :
+ pr:propertyReference
+;
+
+function {
+ startFunction();
+} :
+ ( standardFunction | setFunction ) {
+ finishFunction();
+ }
+;
+
+persisterAliasReference! :
+ a:ALIAS_REF {
+ #persisterAliasReference = resolveAliasReference( #a );
+ }
+;
+
+caseExpression :
+ caseAbbreviation
+ | caseSpecification
+;
+
+caseAbbreviation :
+ #( NULLIF valueExpression valueExpression )
+ | #( COALESCE ( valueExpression )+ )
+;
+
+caseSpecification :
+ simpleCase
+ | searchedCase
+;
+
+simpleCase :
+ #( SIMPLE_CASE valueExpression (simpleCaseWhenClause)+ (elseClause)? END )
+;
+
+simpleCaseWhenClause :
+ #( WHEN valueExpression THEN result )
+;
+
+result :
+ valueExpression
+;
+
+elseClause :
+ #( ELSE result )
+;
+
+searchedCase :
+ #( SEARCHED_CASE (searchedWhenClause)+ (elseClause)? END )
+;
+
+searchedWhenClause :
+ #( WHEN searchCondition THEN valueExpression )
+;
+
+standardFunction :
+ castFunction
+ | concatFunction
+ | substringFunction
+ | trimFunction
+ | upperFunction
+ | lowerFunction
+ | lengthFunction
+ | locateFunction
+ | absFunction
+ | sqrtFunction
+ | modFunction
+ | sizeFunction
+ | indexFunction
+ | currentDateFunction
+ | currentTimeFunction
+ | currentTimestampFunction
+ | extractFunction
+ | positionFunction
+ | charLengthFunction
+ | octetLengthFunction
+ | bitLengthFunction
+;
+
+castFunction :
+ #( CAST valueExpression dataType )
+;
+
+dataType :
+ // todo : temp...
+ IDENT
+;
+
+concatFunction :
+ #( CONCAT (valueExpression)* )
+;
+
+substringFunction :
+ #( SUBSTRING characterValueExpression numericValueExpression (numericValueExpression)? )
+;
+
+trimFunction :
+ #( TRIM ( LEADING | TRAILING | BOTH ) CHAR_STRING characterValueExpression )
+;
+
+upperFunction :
+ #( UPPER characterValueExpression )
+;
+
+lowerFunction :
+ #( LOWER characterValueExpression )
+;
+
+lengthFunction :
+ #( LENGTH characterValueExpression )
+;
+
+locateFunction :
+ #( LOCATE characterValueExpression characterValueExpression (numericValueExpression)? )
+;
+
+absFunction :
+ #( ABS numericValueExpression )
+;
+
+sqrtFunction :
+ #( SQRT numericValueExpression )
+;
+
+modFunction :
+ #( MOD numericValueExpression numericValueExpression )
+;
+
+sizeFunction :
+ #( SIZE collectionPropertyReference )
+;
+
+indexFunction :
+ #( INDEX ALIAS_REF )
+;
+
+currentDateFunction :
+ CURRENT_DATE
+;
+
+currentTimeFunction :
+ CURRENT_TIME
+;
+
+currentTimestampFunction :
+ CURRENT_TIMESTAMP
+;
+
+extractFunction :
+ #( EXTRACT extractField FROM extractSource )
+;
+
+extractField :
+ datetimeField
+ | timeZoneField
+;
+
+datetimeField :
+ nonSecondDatetimeField
+ | SECOND
+;
+
+timeZoneField :
+ TIMEZONE_HOUR
+ | TIMEZONE_MINUTE
+;
+
+extractSource :
+ datetimeValueExpression
+;
+
+positionFunction :
+ #( POSITION characterValueExpression characterValueExpression )
+;
+
+charLengthFunction :
+ #( CHAR_LENGTH characterValueExpression )
+ | #( CHARACTER_LENGTH characterValueExpression )
+;
+
+octetLengthFunction :
+ #( OCTET_LENGTH characterValueExpression )
+;
+
+bitLengthFunction :
+ #( BIT_LENGTH characterValueExpression )
+;
+
+setFunction :
+ #( SUM numericValueExpression )
+ | #( AVG numericValueExpression )
+ | #( MAX numericValueExpression )
+ | #( MIN numericValueExpression )
+ | #( COUNT ( ASTERISK | ( ( DISTINCT | ALL )? ( propertyReference | literal ) ) ) )
+;
+
+collectionFunction :
+ #( MAXELEMENT collectionPropertyReference )
+ | #( MAXINDEX collectionPropertyReference )
+ | #( MINELEMENT collectionPropertyReference )
+ | #( MININDEX collectionPropertyReference )
+;
+
+collectionExpression :
+ #( ELEMENTS collectionPropertyReference )
+ #( INDICES collectionPropertyReference )
+;
+
+parameter :
+ PARAM
+ | JPA_PARAM
+ | NAMED_PARAM
+;
+
+
+// literals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+protected
+literal :
+ javaConstant
+ | numericLiteral
+ | characterLiteral
+ | dateLiteral
+ | timeLiteral
+ | timestampLiteral
+ | intervalLiteral
+;
+
+protected
+javaConstant :
+ JAVA_CONSTANT
+;
+
+protected
+numericLiteral :
+ UNSIGNED_INTEGER
+ | NUM_INT_LITERAL
+ | NUM_LONG_LITERAL
+ | NUM_DOUBLE_LITERAL
+ | NUM_FLOAT_LITERAL
+;
+
+protected
+characterLiteral :
+ CHAR_STRING
+ | NATIONAL_CHAR_STRING_LIT
+ | BIT_STRING_LIT
+ | HEX_STRING_LIT
+;
+
+protected
+dateLiteral :
+// #( DATE CHAR_STRING )
+ #( DATE characterValueExpression )
+;
+
+protected
+timeLiteral :
+// #( TIME CHAR_STRING )
+ #( TIME characterValueExpression )
+;
+
+protected
+timestampLiteral :
+// #( TIMESTAMP CHAR_STRING )
+ #( TIMESTAMP characterValueExpression )
+;
+
+protected
+intervalLiteral :
+ #( INTERVAL ( PLUS_SIGN | MINUS_SIGN )? CHAR_STRING intervalQualifier )
+// #( INTERVAL ( PLUS_SIGN | MINUS_SIGN )? characterValueExpression intervalQualifier ) -- characterValueExpression causes non-determinism with + and -
+;
+
+protected
+intervalQualifier :
+ #( YEAR (precision)? ( TO MONTH )? )
+ | #( MONTH (precision)? )
+ | #( DAY (precision)? ( TO ( HOUR | MINUTE | ( SECOND (scale)? ) ) )? )
+ | #( HOUR (precision)? ( TO ( MINUTE | SECOND (scale)? ) )? )
+ | #( MINUTE (precision)? ( TO SECOND (scale)? )? )
+ | #( SECOND ( precision (scale)? )? )
+;
+
+precision :
+ NUM_INT_LITERAL
+;
+
+scale :
+ NUM_INT_LITERAL
+;
+
+//protected
+//intervalStartField :
+// nonSecondDatetimeField ( LEFT_PAREN UNSIGNED_INTEGER RIGHT_PAREN )?
+//;
+//
+//protected
+//intervalEndField :
+// nonSecondDatetimeField
+// | SECOND ( LEFT_PAREN UNSIGNED_INTEGER RIGHT_PAREN )?
+//;
+
+protected
+nonSecondDatetimeField :
+ YEAR
+ | MONTH
+ | DAY
+ | HOUR
+ | MINUTE
+;
+
+
+
+// Search conditions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+/**
+ * Main logical/conditional rule defining boolean evaluated expressions
+ * <p/>
+ * This first level handles OR expressions
+ */
+searchCondition :
+ #( OR searchCondition searchCondition )
+ | #( AND searchCondition searchCondition )
+ | #( NOT searchCondition )
+ | predicate
+;
+
+predicate :
+ #( EQUALS_OP rowValueConstructor comparativePredicateValue )
+ | #( NOT_EQUALS_OP rowValueConstructor comparativePredicateValue )
+ | #( LESS_THAN_OP rowValueConstructor comparativePredicateValue )
+ | #( LESS_THAN_OR_EQUALS_OP rowValueConstructor comparativePredicateValue )
+ | #( GREATER_THAN_OP rowValueConstructor comparativePredicateValue )
+ | #( GREATER_THAN_OR_EQUALS_OP rowValueConstructor comparativePredicateValue )
+ | #( IS_NULL rowValueConstructor )
+ | #( IS_NOT_NULL rowValueConstructor )
+ | #( LIKE valueExpression valueExpression (escapeSpecification)? )
+ | #( NOT_LIKE valueExpression valueExpression (escapeSpecification)? )
+ | #( BETWEEN rowValueConstructor rowValueConstructor rowValueConstructor )
+ | #( NOT_BETWEEN rowValueConstructor rowValueConstructor rowValueConstructor )
+ | #( IN rowValueConstructor inPredicateValue )
+ | #( NOT_IN rowValueConstructor inPredicateValue )
+ | #( EXISTS (
+ queryExpression
+ | ( ELEMENTS | INDICES ) collectionPropertyReference
+ )
+ )
+;
+
+comparativePredicateValue :
+ rowValueConstructor
+ | ( ( SOME | ALL | ANY ) subquery )
+;
+
+escapeSpecification :
+ #( ESCAPE characterValueExpression )
+;
+
+inPredicateValue :
+ #(
+ IN_LIST (
+ queryExpression
+ | ( valueExpression )+
+ )
+ )
+;
+
+rowValueConstructor :
+ ( LEFT_PAREN ) => ( LEFT_PAREN rowValueConstructorList RIGHT_PAREN )
+ | rowValueConstructorElement
+;
+
+rowValueConstructorElement :
+ valueExpression
+ | NULL
+ | DEFAULT
+;
+
+rowValueConstructorList :
+ rowValueConstructorElement ( COMMA! rowValueConstructorElement )*
+;
Modified: core/branches/SQL_GEN_REDESIGN/src/main/antlr/sql/common.g
===================================================================
--- core/branches/SQL_GEN_REDESIGN/src/main/antlr/sql/common.g 2009-02-09 11:19:30 UTC (rev 15916)
+++ core/branches/SQL_GEN_REDESIGN/src/main/antlr/sql/common.g 2009-02-09 18:30:53 UTC (rev 15917)
@@ -36,6 +36,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
+import org.hibernate.util.StringHelper;
}
/**
@@ -197,6 +199,8 @@
ORDER_BY;
GROUP_BY;
+ ROW_VALUE_CONSTRUCTOR_LIST;
+
// synthetic numeric literal types
NUM_INT_LITERAL;
NUM_LONG_LITERAL;
@@ -235,8 +239,39 @@
{
private static final Logger log = LoggerFactory.getLogger( CommonHibernateParserSupport.class );
- // Grammar actions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ private int traceDepth = 0;
+ /**
+ * {@inheritDoc}
+ */
+ public void traceIn(String s) throws TokenStreamException {
+ if ( inputState.guessing > 0 ) {
+ return;
+ }
+ String prefix = StringHelper.repeat( "-", (traceDepth++ * 2) ) + "->";
+ traceExecution( prefix + s );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void traceOut(String s) throws TokenStreamException {
+ if ( inputState.guessing > 0 ) {
+ return;
+ }
+ String prefix = "<-" + StringHelper.repeat( "-", (--traceDepth * 2) );
+ traceExecution( prefix + s );
+ }
+
+ /**
+ * Perform trace logging. Called from both {@link #traceIn} and {@link #traceOut}.
+ *
+ * @param msg The trace string
+ */
+ protected void traceExecution(String msg) {
+ log.trace( msg );
+ }
+
public void showAST(AST ast) {
showAST( ast, "AST" );
}
15 years, 3 months
Hibernate SVN: r15916 - in validator/trunk/hibernate-validator: src/main/docbook/en-US and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-09 06:19:30 -0500 (Mon, 09 Feb 2009)
New Revision: 15916
Added:
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml
Modified:
validator/trunk/hibernate-validator/pom.xml
validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
Log:
attached the documentation build to site phase; added Gunnar's doc changes
Modified: validator/trunk/hibernate-validator/pom.xml
===================================================================
--- validator/trunk/hibernate-validator/pom.xml 2009-02-08 18:51:25 UTC (rev 15915)
+++ validator/trunk/hibernate-validator/pom.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
@@ -54,20 +54,6 @@
</resources>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>apt-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-process</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <testOutputDirectory>${project.build.directory}/site</testOutputDirectory>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
<version>2.1.0</version>
@@ -95,14 +81,12 @@
</format>
<format>
<formatName>html_single</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-single.xsl
- </stylesheetResource>
+ <stylesheetResource>classpath:/xslt/hibernate/html/main-single.xsl </stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html</formatName>
- <stylesheetResource>classpath:/xslt/hibernate/html/main-chunk.xsl
- </stylesheetResource>
+ <stylesheetResource>classpath:/xslt/hibernate/html/main-chunk.xsl </stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
@@ -115,7 +99,7 @@
<executions>
<execution>
<id>make-doc</id>
- <phase>package</phase>
+ <phase>site</phase>
<goals>
<goal>resources</goal>
<goal>generate</goal>
Modified: validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-02-08 18:51:25 UTC (rev 15915)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/master.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -1,4 +1,4 @@
-<?xml version='1.0' encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
@@ -24,13 +24,13 @@
-->
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY versionNumber "4.0.0.Alpha1">
- <!ENTITY copyrightYear "2004">
- <!ENTITY copyrightHolder "Red Hat Middleware, LLC.">
+ <!ENTITY copyrightYear "2009">
+ <!ENTITY copyrightHolder "Red Hat Middleware, LLC. & Gunnar Morling">
]>
<book lang="en">
<bookinfo>
- <title>Hibernate Validator</title>
+ <title>Hibernate Validator (Bean Validation API reference implementation)</title>
<subtitle>Reference Guide</subtitle>
<releaseinfo>&versionNumber;</releaseinfo>
<productnumber>&versionNumber;</productnumber>
@@ -87,6 +87,16 @@
<classname>ResourceBundle</classname> .</para>
</preface>
+ <xi:include href="modules/introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/gettingstarted.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/usingvalidator.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/customconstraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/xmlconfiguration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/integration.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="modules/extendedri.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+<!--
<xi:include href="modules/defineconstraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="modules/checkconstraints.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-</book>
\ No newline at end of file
+-->
+</book>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/customconstraints.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="validator-customconstraints">
+ <title>Creating custom constraints</title>
+
+ <para>The Bean Validation API doesn't restrict you to the constraints
+ specified by the API itself, but rather allows you to create your own custom
+ constraints in a simple and timely manner.</para>
+
+ <section id="validator-customconstraints-constraintannotation" revision="1">
+ <title>Create a constraint annotation</title>
+
+ <para></para>
+ </section>
+
+ <section id="validator-customconstraints-validator" revision="1">
+ <title>Implement the constraint validator</title>
+
+ <para></para>
+ </section>
+
+ <section id="validator-customconstraints-errormessage" revision="1">
+ <title>Define the error message</title>
+
+ <para></para>
+ </section>
+
+ <section id="validator-customconstraints-compound" revision="1">
+ <title>Compound constraints</title>
+
+ <para></para>
+ </section>
+</chapter>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/extendedri.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+ <chapter id="validator-extendedri">
+ <title>Extended features of Bean Validation reference implementation</title>
+
+<section id="validator-extendedri-constraintannotations"
+ revision="1">
+ <title>Additional constraint annotations</title>
+</section>
+
+ </chapter>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/gettingstarted.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,355 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="validator-gettingstarted">
+ <title>Getting started with Bean Validation RI in 5 minutes</title>
+
+ <para>This chapter will show you how to quickly get started with the
+ reference implementation (RI) of the Bean Validation API as specified by
+ <ulink url="http://jcp.org/en/jsr/detail?id=303">JSR 303</ulink>. Be sure to
+ fulfill the following prerequisites in order to proceed:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>As the Bean Validation API expresses constraints by the means of
+ annotations, Java version 5 is or later must be installed</para>
+ </listitem>
+
+ <listitem>
+ <para>As <ulink url="http://maven.apache.org/">Apache Maven</ulink> will
+ be used as build tool in the following, Maven must be installed (help
+ can be found <ulink
+ url="http://maven.apache.org/download.html">here</ulink>) and a
+ functioning internet connection is required to allow Maven for the
+ download of all dependent libraries</para>
+ </listitem>
+ </itemizedlist>
+
+ <section id="validator-gettingstarted-buildri" revision="1">
+ <title>Build RI. TODO GM: Remove, if RI is in repo</title>
+
+ <para>As the Bean Validation RI is not yet published in any Maven
+ repository, you have to check it out from the Subversion repository at
+ JBoss and build it yourself. The project can be checked out as
+ follows:</para>
+
+ <programlisting>svn co http://anonsvn.jboss.org/repos/hibernate/validator/trunk/</programlisting>
+
+ <para>If all files are checked out, change into the trunk dir and build
+ the reference implementation by running</para>
+
+ <programlisting>mvn install</programlisting>
+
+ <para>If the build has completed, the JSR 303 API and the reference
+ implementation have been installed into your local Maven repository and
+ can now be used in your projects.</para>
+ </section>
+
+ <section id="validator-gettingstarted-createproject" revision="1">
+ <title>Setting up a new Maven project</title>
+
+ <para>Start by creating new Maven project using the Maven archetype plugin
+ as follows:</para>
+
+ <para><programlisting>mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart</programlisting></para>
+
+ <para>and specify the requested properties:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>groupId: An identifier for your company, e.g.
+ com.mycompany</para>
+ </listitem>
+
+ <listitem>
+ <para>artifactId: An identifier for the new project, e.g.
+ beanvalidation-gettingstarted</para>
+ </listitem>
+
+ <listitem>
+ <para>version: Initial version for the new project, e.g.
+ 1.0-SNAPSHOT</para>
+ </listitem>
+
+ <listitem>
+ <para>package: The top-level package for the new project, e.g.
+ com.mycompany</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Finally confirm all entered values and change into the newly created
+ project directory. All properties of a Maven project (such as its
+ dependencies to other libraries, the steps to be performed during build
+ etc.) are described in a file contained pom.xml (project object model),
+ located in the project's root directory. Now open the project's pom.xml
+ and perform the following changes:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>Add the dependencies to the Bean Validation API and the
+ reference implementation</para>
+ </listitem>
+
+ <listitem>
+ <para>Set the compiler level to 1.5 (as we want to use
+ annotations)</para>
+ </listitem>
+
+ <listitem>
+ <para>Use JUnit 4 as testing framework</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>Having done this, your pom.xml should look like this (TODO GM: keep
+ an eye on versions):</para>
+
+ <programlisting><project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.mycompany</groupId>
+ <artifactId>beanvalidation-gettingstarted</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>RELEASE</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project></programlisting>
+ </section>
+
+ <section id="validator-gettingstarted-createmodel" revision="1">
+ <title>Applying constraints to a model class</title>
+
+ <para>Having set up the project, it's time now to actually make use of the
+ Bean Validation API. Therefore, open the project in the IDE of you choice
+ (for Eclipse, you may type mvn eclipse:eclipse to create a standard
+ Eclipse project configuration OR you may use the <ulink
+ url="http://m2eclipse.codehaus.org/">M2Eclipse</ulink> plugin. NetBeans
+ has great Maven support too, as described <ulink
+ url="http://wiki.netbeans.org/MavenBestPractices">here</ulink>) and create
+ the following class as an exemplary domain object:</para>
+
+ <para><programlisting>package com.mycompany;
+
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+public class Car {
+
+ @NotNull
+ private String manufacturer;
+
+ @NotNull
+ @Size(min = 2, max = 14)
+ private String licensePlate;
+
+ @Min(2)
+ private int seatCount;
+
+ public Car(String manufacturer, String licencePlate, int seatCount) {
+
+ this.manufacturer = manufacturer;
+ this.licensePlate = licencePlate;
+ this.seatCount = seatCount;
+ }
+
+ //getters and setters ...
+
+}</programlisting></para>
+
+ <para>@NotNull, @Size and @Min are so-called constraint annotions, that we
+ use to declare certain constraints, which shall be applied to the fields
+ of a Car instance:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>manufacturer shall never be null</para>
+ </listitem>
+
+ <listitem>
+ <para>licensePlate shall never be null and must be between 2 and 14
+ characters long</para>
+ </listitem>
+
+ <listitem>
+ <para>seatCount shall be at least 2.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>To perform a validation of these constraints, we use the Validator
+ interface defined by the specification. Let's try it in a test for our Car
+ class:</para>
+
+ <para><programlisting>package com.mycompany;
+
+import static org.junit.Assert.*;
+
+import java.util.Set;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CarTest {
+
+ private static Validator validator;
+
+ @BeforeClass
+ public static void setUp() {
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ validator = factory.getValidator();
+ }
+
+ @Test
+ public void manufacturerIsNull() {
+
+ Car car = new Car(null, "DD-AB-123", 4);
+
+ Set<ConstraintViolation<Car>> constraintViolations =
+ validator.validate(car);
+
+ assertEquals(1, constraintViolations.size());
+ assertEquals(
+ "may not be null", constraintViolations.iterator().next().getInterpolatedMessage());
+ }
+
+ @Test
+ public void licensePlateTooShort() {
+
+ Car car = new Car("Morris", "D", 4);
+
+ Set<ConstraintViolation<Car>> constraintViolations =
+ validator.validate(car);
+
+ assertEquals(1, constraintViolations.size());
+ assertEquals(
+ "size must be between 2 and 14", constraintViolations.iterator().next().getInterpolatedMessage());
+ }
+
+ @Test
+ public void seatCountTooLow() {
+
+ Car car = new Car("Morris", "DD-AB-123", 1);
+
+ Set<ConstraintViolation<Car>> constraintViolations =
+ validator.validate(car);
+
+ assertEquals(1, constraintViolations.size());
+ assertEquals(
+ "must be greater than 2", constraintViolations.iterator().next().getInterpolatedMessage());
+ }
+
+ @Test
+ public void carIsValid() {
+
+ Car car = new Car("Morris", "DD-AB-123", 2);
+
+ Set<ConstraintViolation<Car>> constraintViolations =
+ validator.validate(car);
+
+ assertEquals(0, constraintViolations.size());
+ }
+}</programlisting></para>
+
+ <para>In the setUp() method we get a Validator object from the
+ ValidatorFactory. A Validator instance is thread-safe and may be reused
+ multiple times, therefore we store it as field of our test class. We can
+ use the validator now to validate the different car objects in the test
+ methods.</para>
+
+ <para>The validate() method returns a set of ConstraintViolation objects,
+ which we can iterate through in order to see which validation errors
+ occured. The first three test methods show some expected constraint
+ violations:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The @NotNull constraint on manufacturer is violated in
+ manufacturerIsNull()</para>
+ </listitem>
+
+ <listitem>
+ <para>The @Size constraint on licensePlate is violated in
+ licensePlateTooShort()</para>
+ </listitem>
+
+ <listitem>
+ <para>The @Min constraint on seatCount is violated in
+ seatCountTooLow()</para>
+ </listitem>
+ </itemizedlist>
+
+ <para>If the object could be validated successfully (as in carIsValid()),
+ validate() returns an empty set.</para>
+
+ <para>Note that we only use classes from the package javax.validation,
+ which stems from the Bean Validation standard API. As we don't reference
+ any classes of the RI directly, it would be no problem to switch to
+ another implementation of the API, should that need arise.</para>
+ </section>
+
+ <section id="validator-gettingstarted-whatsnext" revision="1">
+ <title>Where to go next?</title>
+
+ <para>That concludes our 5 minute tour through the world of the Bean
+ Validation RI. You might next be interested in using some <link
+ linkend="validator-usingvalidator">advanced features of the Validator
+ API</link> or how to define your own <link
+ linkend="validator-customconstraints">custom constraint</link>.</para>
+ </section>
+</chapter>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/integration.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+ <chapter id="validator-integration">
+ <title>Integrating Bean Validation RI with other frameworks</title>
+ </chapter>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/introduction.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<chapter id="validator-introduction">
+ <title>Introduction</title>
+
+ <section id="validator-introduction-whatisit" revision="1">
+ <title>What is it about?</title>
+
+ <para></para>
+ </section>
+
+ <section id="validator-introduction-installation" revision="1">
+ <title>Installation</title>
+
+ <para>
+
+ <section revision="1">
+ <title>Prerequisites</title>
+
+ <para></para>
+ </section>
+ <section revision="1">
+ <title>Running Bean Validation RI with downloaded JARs</title>
+
+ <para></para>
+ </section>
+ <section revision="1">
+ <title>Running Bean Validation RI using Maven</title>
+
+ <para></para>
+ </section>
+ <section revision="1">
+ <title>Building Bean Validation RI from the sources</title>
+
+ <para></para>
+ </section>
+ </para>
+ </section>
+
+</chapter>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/usingvalidator.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="validator-usingvalidator">
+ <title>Using the Validator API</title>
+
+ <section id="validator-usingvalidator-annotate" revision="1">
+ <title>Annotate your model</title>
+
+ <para>Field, Getter</para>
+ </section>
+
+ <section id="validator-usingvalidator-validate" revision="1">
+ <title>Object validation</title>
+
+ <para>Plain, Use of @Valid</para>
+ </section>
+
+ <section id="validator-usingvalidator-validationgroups" revision="1">
+ <title>Validation groups</title>
+
+ <para><section revision="1">
+ <title>Group sequences</title>
+
+ <para />
+ </section></para>
+ </section>
+
+ <section id="validator-usingvalidator-methodparameters" revision="1">
+ <title>Validating method parameters</title>
+
+ <para></para>
+ </section>
+</chapter>
Added: validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml
===================================================================
--- validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml (rev 0)
+++ validator/trunk/hibernate-validator/src/main/docbook/en-US/modules/xmlconfiguration.xml 2009-02-09 11:19:30 UTC (rev 15916)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2008, 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
+ -->
+
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+ <chapter id="validator-xmlconfiguration">
+ <title>Using XML for constraint configuration</title>
+ </chapter>
15 years, 3 months
Hibernate SVN: r15915 - validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-02-08 13:51:25 -0500 (Sun, 08 Feb 2009)
New Revision: 15915
Added:
validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties
Log:
added a ValidationMessages for German
Added: validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties
===================================================================
--- validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties (rev 0)
+++ validator/trunk/hibernate-validator/src/main/resources/org/hibernate/validation/ValidationMessages_de.properties 2009-02-08 18:51:25 UTC (rev 15915)
@@ -0,0 +1,11 @@
+# $Id: ValidationMessages.properties 15846 2009-02-02 11:56:15Z hardy.ferentschik $
+validator.notNull=kann nicht null sein
+validator.size=muss zwischen {min} und {max} liegen
+validator.length=muss zwischen {min} und {max} liegen
+validator.notEmpty=kann nicht leer sein
+validator.pattern=muss auf Ausdruck "{regex}" passen
+validator.min=muss grösser sein als {value}
+validator.max=muss kleiner sein als {value}
+validator.null=muss null sein
+validator.past=muss in der Vergangenheit liegen
+validator.future=muss in der Zukunft liegen
15 years, 3 months
Hibernate SVN: r15914 - validator/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-02-07 10:59:17 -0500 (Sat, 07 Feb 2009)
New Revision: 15914
Modified:
validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
Log:
Typos
Modified: validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java
===================================================================
--- validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-02-06 23:46:33 UTC (rev 15913)
+++ validator/trunk/validation-api/src/main/java/javax/validation/ConstraintValidator.java 2009-02-07 15:59:17 UTC (rev 15914)
@@ -30,18 +30,18 @@
*/
public interface ConstraintValidator<A extends Annotation, T> {
/**
- * Validator parameters for a given constraint definition
+ * Validator parameters for a given constraint declaration
* Annotations parameters are passed as key/value into parameters
* <p/>
* This method is guaranteed to be called before any of the other Constraint
* implementation methods
*
- * @param constraintAnnotation parameters for a given constraint definition
+ * @param constraintAnnotation parameters for a given constraint declaration
*/
void initialize(A constraintAnnotation);
/**
- * Implement the validation constraint.
+ * Implement the validation logic.
* <code>object</code> state must not be changed by a Constraint implementation
*
* @param object object to validate
15 years, 3 months