Hibernate SVN: r17231 - in beanvalidation/trunk/validation-tck/src/main: resources and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-08-05 12:13:53 -0400 (Wed, 05 Aug 2009)
New Revision: 17231
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
message interpolation tests
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-08-04 22:04:27 UTC (rev 17230)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/messageinterpolation/MessageInterpolationTest.java 2009-08-05 16:13:53 UTC (rev 17231)
@@ -17,6 +17,7 @@
*/
package org.hibernate.jsr303.tck.tests.messageinterpolation;
+import java.util.Date;
import java.util.Locale;
import java.util.Set;
import javax.validation.ConstraintViolation;
@@ -24,6 +25,7 @@
import javax.validation.Validator;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Past;
import javax.validation.constraints.Size;
import javax.validation.metadata.ConstraintDescriptor;
@@ -37,6 +39,7 @@
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import org.testng.annotations.Test;
@@ -75,7 +78,7 @@
public void testSuccessfullInterpolationOfValidationMessagesValue() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "foo" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "replacement worked";
@@ -99,7 +102,7 @@
@SpecAssertion(section = "4.3.1.1", id = "b")
public void testRecursiveMessageInterpoliation() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "fubar" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "fubar" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "recursion worked";
@@ -132,7 +135,7 @@
public void testLiteralCurlyBraces() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "foo" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "{";
@@ -152,7 +155,7 @@
@SpecAssertion(section = "4.3.1.1", id = "a")
public void testUnSuccessfulInterpolation() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "foo" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "foo"; // missing {}
@@ -168,7 +171,7 @@
@SpecAssertion(section = "4.3.1.1", id = "a")
public void testUnkownTokenInterpolation() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "foo" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "{bar}"; // unkown token {}
@@ -177,10 +180,25 @@
}
@Test
+ @SpecAssertion(section = "4.3.1.1", id = "c")
+ public void testParametersAreExtractedFromBeanValidationProviderBundle() {
+ MessageInterpolator interpolator = getDefaultMessageInterpolator();
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( Person.class, "birthday" );
+ MessageInterpolator.Context context = new TestContext( descriptor );
+
+ String key = "{javax.validation.constraints.Past.message}"; // Past is a builtin constraint so the provider must provide a default message
+ String actual = interpolator.interpolate( key, context );
+ assertFalse(
+ key.equals( actual ),
+ "There should have been a message interpolation from the bean validator provider bundle."
+ );
+ }
+
+ @Test
@SpecAssertion(section = "4.3.1.1", id = "g")
- public void testDefaultInterpolation() {
+ public void testConstraintAttributeValuesAreInterpolated() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "bar" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "bar" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "size must be between 5 and 10";
@@ -192,7 +210,7 @@
@SpecAssertion(section = "4.3.1.1", id = "h")
public void testMessageInterpolationWithLocale() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "foo" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "kann nicht null sein";
@@ -206,7 +224,7 @@
@SpecAssertion(section = "4.3.1.1", id = "i")
public void testFallbackToDefaultLocale() {
MessageInterpolator interpolator = getDefaultMessageInterpolator();
- ConstraintDescriptor<?> descriptor = getDescriptorFor( "foo" );
+ ConstraintDescriptor<?> descriptor = getDescriptorFor( DummyEntity.class, "foo" );
MessageInterpolator.Context context = new TestContext( descriptor );
String expected = "may not be null";
@@ -220,9 +238,9 @@
assertEquals( actual, expected, "Wrong substitution" );
}
- private ConstraintDescriptor<?> getDescriptorFor(String propertyName) {
+ private ConstraintDescriptor<?> getDescriptorFor(Class<?> clazz, String propertyName) {
Validator validator = getValidatorUnderTest();
- return validator.getConstraintsForClass( DummyEntity.class )
+ return validator.getConstraintsForClass( clazz )
.getConstraintsForProperty( propertyName )
.getConstraintDescriptors()
.iterator()
@@ -258,4 +276,12 @@
@NotNull(message = "messages can also be overridden at constraint declaration.")
String snafu;
}
+
+ public class Person {
+
+ String name;
+
+ @Past
+ Date birthday;
+ }
}
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-04 22:04:27 UTC (rev 17230)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-08-05 16:13:53 UTC (rev 17231)
@@ -281,22 +281,26 @@
are used</text>
</assertion>
<assertion id="c">
- <text>Array of objects is supported by @Valid. The content of the array is validated.</text>
+ <text>Array of objects is supported by @Valid. The content of the array is
+ validated.</text>
</assertion>
<assertion id="d">
- <text>java.util.Collection is supported by @Valid. The content of the collection is validated.</text>
+ <text>java.util.Collection is supported by @Valid. The content of the collection is
+ validated.</text>
</assertion>
<assertion id="e">
<text>java.util.Set is supported by @Valid. The content of the Set is validated.</text>
</assertion>
<assertion id="f">
- <text>java.util.List is supported by @Valid. The content of the list is validated.</text>
+ <text>java.util.List is supported by @Valid. The content of the list is
+ validated.</text>
</assertion>
<assertion id="g">
<text>java.util.Map is supported by @Valid</text>
</assertion>
<assertion id="h">
- <text>java.lang.Iterable is supported by @Valid. The elements of the iterable are validated</text>
+ <text>java.lang.Iterable is supported by @Valid. The elements of the iterable are
+ validated</text>
</assertion>
<assertion id="i">
<text>For Map, the value of each entry is validated (the key is not validated)</text>
@@ -374,8 +378,9 @@
is raised.</text>
</assertion>
<assertion id="g" testable="false">
- <text>Groups defining a sequence should not directly inherit other groups. In other words, the interface hosting the group
- sequence should not have any super interface.</text>
+ <text>Groups defining a sequence should not directly inherit other groups. In other
+ words, the interface hosting the group sequence should not have any super
+ interface.</text>
</assertion>
<assertion id="h" testable="false">
<text>Groups defining a sequence should not be used directly in constraint
@@ -452,16 +457,18 @@
</section>
<section id="3.5.2" title="Traversable property">
<assertion id="a">
- <text>isReachable is called for every property about to be accessed either for validation or for cascading</text>
+ <text>isReachable is called for every property about to be accessed either for
+ validation or for cascading</text>
</assertion>
<assertion id="b">
- <text>isCascadable is called for every property about to be cascaded (ie. marked as @Valid)</text>
+ <text>isCascadable is called for every property about to be cascaded (ie. marked as
+ @Valid)</text>
</assertion>
<assertion id="c">
<text>isCascadable for a given property is only called if isReachable returns true. In
other words, isReachable is always called before isCascadable for a given
property</text>
- </assertion>
+ </assertion>
<assertion id="d">
<text>The Bean Validation provider must not access the state of a property, nor validate
its constraints if the property is not traversable. A property is traversable if
@@ -480,7 +487,8 @@
are considered reachable</text>
</assertion>
<assertion id="h" testable="false">
- <text>If Java Persistence is not available in the runtime environment, all properties are considered cascadable</text>
+ <text>If Java Persistence is not available in the runtime environment, all properties
+ are considered cascadable</text>
</assertion>
</section>
<section id="3.5.3" title="ConstraintValidator resolution algorithm">
@@ -524,7 +532,8 @@
<text>validate(T object, Class... groups) is used to validate a given object</text>
</assertion>
<assertion id="b">
- <text>An IllegalArgumentException is thrown when validateProperty is called and object is null or null is passed to the varargs groups.</text>
+ <text>An IllegalArgumentException is thrown when validateProperty is called and object
+ is null or null is passed to the varargs groups.</text>
</assertion>
<assertion id="c">
<text>A Set containing all ConstraintViolation objects representing the failing
@@ -535,12 +544,13 @@
field or property of an object</text>
</assertion>
<assertion id="e">
- <text>An IllegalArgumentException is thrown when validateProperty is called and object is null or propertyName is null
- empty or invalid or null is passed to the varargs groups.</text>
+ <text>An IllegalArgumentException is thrown when validateProperty is called and object
+ is null or propertyName is null empty or invalid or null is passed to the varargs
+ groups.</text>
</assertion>
<assertion id="f">
- <text>The property name in validateProperty is the JavaBeans property name (as defined by the JavaBeans
- Introspector class)</text>
+ <text>The property name in validateProperty is the JavaBeans property name (as defined
+ by the JavaBeans Introspector class)</text>
</assertion>
<assertion id="g">
<text>@Valid is not honored by a call to validateProperty.</text>
@@ -551,8 +561,9 @@
superclasses, if the property value were value.</text>
</assertion>
<assertion id="i">
- <text>An IllegalArgumentException is thrown when validateValue is called and object is null or propertyName is null
- empty or invalid or null is passed to the varargs groups.</text>
+ <text>An IllegalArgumentException is thrown when validateValue is called and object is
+ null or propertyName is null empty or invalid or null is passed to the varargs
+ groups.</text>
</assertion>
<assertion id="j">
<text>@Valid is not honored by validateValue.</text>
@@ -564,7 +575,8 @@
</section>
<section id="4.1.2" title="groups">
<assertion id="a">
- <text>All constraints belonging to the targeted group are applied during the validation routine.</text>
+ <text>All constraints belonging to the targeted group are applied during the validation
+ routine.</text>
</assertion>
<assertion id="b">
<text>If no group is passed, the Default group is assumed</text>
@@ -594,37 +606,38 @@
<text>getConstraintDescriptor provides access to the failing constraint metadata</text>
</assertion>
<assertion id="f">
- <text>getPropertyPath returns the Path object representing the navigation path from the root object to the failing
- object</text>
- </assertion>
+ <text>getPropertyPath returns the Path object representing the navigation path from the
+ root object to the failing object</text>
+ </assertion>
<assertion id="g">
- <text>If the failing object is the root object, the property path consists of a single Node with name set to null.</text>
- </assertion>
+ <text>If the failing object is the root object, the property path consists of a single
+ Node with name set to null.</text>
+ </assertion>
<assertion id="h">
- <text>If failing object is traversed, a Node object whose name equals the name of the association property (field name or Java Bean property
- name) is added to Path.
+ <text>If failing object is traversed, a Node object whose name equals the name of the
+ association property (field name or Java Bean property name) is added to Path.
</text>
- </assertion>
+ </assertion>
<assertion id="i">
- <text>If the traversed association is a List or an array, the added Node object contains the index value in getIndex.
- </text>
- </assertion>
+ <text>If the traversed association is a List or an array, the added Node object contains
+ the index value in getIndex. </text>
+ </assertion>
<assertion id="j">
- <text>If the association is a Map, the added Node object (representing a given map entry) contains the key value in getKey
- </text>
- </assertion>
+ <text>If the association is a Map, the added Node object (representing a given map
+ entry) contains the key value in getKey </text>
+ </assertion>
<assertion id="k">
- <text>For all Iterable or Map, the added Node object added is marked as inIterable (isInIterable)
- </text>
+ <text>For all Iterable or Map, the added Node object added is marked as inIterable
+ (isInIterable) </text>
</assertion>
<assertion id="l">
- <text>For a property level constraint (field and getter) a Node object is added to Path whose name equals the name of the property.
- </text>
- </assertion>
+ <text>For a property level constraint (field and getter) a Node object is added to Path
+ whose name equals the name of the property. </text>
+ </assertion>
<assertion id="m">
- <text>For a class level constraint a Node object is added to Path whose name is null
+ <text>For a class level constraint a Node object is added to Path whose name is null
</text>
- </assertion>
+ </assertion>
</section>
<section id="4.3.1" title="Default message interpolation">
<assertion id="a">
@@ -672,10 +685,12 @@
locale. If a property is found, the message parameter is replaced with the property
value in the message string (step 2)</text>
</assertion>
- <assertion id="e">
+ <assertion id="e" testable="false">
+ <!-- in order to test one would have to make assumptions about the provider specific resource bundle -->
<text>Contrary to step 1, step 2 is not processed recursively</text>
</assertion>
- <assertion id="f">
+ <assertion id="f" testable="false">
+ <!-- in order to test one would have to make assumptions about the provider specific resource bundle -->
<text>If step 2 triggers a replacement, then step 1 is applied again</text>
</assertion>
<assertion id="g">
@@ -684,11 +699,12 @@
value of that attribute.</text>
</assertion>
<assertion id="h">
- <text>if the locale is passed to the interpolator method interpolate(String,
+ <text>If the locale is passed to the interpolator method interpolate(String,
CosntraintDescriptor, Object, Locale), this Locale instance is used</text>
</assertion>
<assertion id="i">
- <text>otherwise, the default Locale as provided by Locale.getDefault() is used.</text>
+ <text>If the locale is not specified, the default Locale as provided by
+ Locale.getDefault() is used.</text>
</assertion>
</section>
<section id="4.3.2" title="Custom message interpolation">
@@ -807,9 +823,8 @@
providers</text>
</assertion>
<assertion id="c">
- <text>When building the Configuration object, if the ValidationProviderResolver
- fais or if the expected provider is not found, a ValidationException is
- raised</text>
+ <text>When building the Configuration object, if the ValidationProviderResolver fais or
+ if the expected provider is not found, a ValidationException is raised</text>
</assertion>
</section>
<section id="4.4.6" title="XML Configuration">
@@ -893,12 +908,14 @@
invalid, a ValidationException is raised</text>
</assertion>
<assertion id="b">
- <text>Validator.getConstraintsForClass returns a BeanDescriptor object describing the bean level constraints
- and providing access to the property level constraints metadata. </text>
- </assertion>
+ <text>Validator.getConstraintsForClass returns a BeanDescriptor object describing the
+ bean level constraints and providing access to the property level constraints
+ metadata. </text>
+ </assertion>
<assertion id="c">
- <text>Validator.getConstraintsForClass throws an IllegalArgumentException if the clazz parameter is null</text>
- </assertion>
+ <text>Validator.getConstraintsForClass throws an IllegalArgumentException if the clazz
+ parameter is null</text>
+ </assertion>
</section>
<section id="5.3" title="BeanDescriptor">
<assertion id="a">
14 years, 8 months
Hibernate SVN: r17230 - beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-08-04 18:04:27 -0400 (Tue, 04 Aug 2009)
New Revision: 17230
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
Log:
fix various incorrent assumptions on the implementation detail
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-08-04 20:59:22 UTC (rev 17229)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-08-04 22:04:27 UTC (rev 17230)
@@ -65,7 +65,7 @@
final Set<ConstraintViolation<Shoe>> constraintViolations = validator.validate( shoe );
assertEquals( 1, constraintViolations.size() );
assertTrue(
- BoundariesConstraintValidator.isValidCalls == 1,
+ BoundariesConstraintValidator.isValidCalls >= 1,
"Ensure the right validator implementation class was picked."
);
assertTrue(
@@ -84,29 +84,32 @@
Validator validator = TestUtil.getValidatorUnderTest();
Shoe shoe = new Shoe();
shoe.size = -2;
-
+ int nbrOfValidCalls = 0;
BoundariesConstraintValidator.isValidCalls = 0;
validator.validate( shoe );
assertTrue(
- BoundariesConstraintValidator.isValidCalls == 1,
+ BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
"Ensure is valid hasbeen called."
);
+ nbrOfValidCalls = BoundariesConstraintValidator.isValidCalls;
validator.validate( shoe );
assertTrue(
- BoundariesConstraintValidator.isValidCalls == 2,
+ BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
"Ensure is valid hasbeen called."
);
+ nbrOfValidCalls = BoundariesConstraintValidator.isValidCalls;
validator.validateProperty( shoe, "size" );
assertTrue(
- BoundariesConstraintValidator.isValidCalls == 3,
+ BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
"Ensure is valid hasbeen called."
);
+ nbrOfValidCalls = BoundariesConstraintValidator.isValidCalls;
validator.validateValue( Shoe.class, "size", 41 );
assertTrue(
- BoundariesConstraintValidator.isValidCalls == 4,
+ BoundariesConstraintValidator.isValidCalls > nbrOfValidCalls,
"Ensure is valid hasbeen called."
);
}
@@ -165,7 +168,7 @@
@Test
@SpecAssertion(section = "2.4", id = "n")
- public void testNonInterpolatedMessageParamterIsUsed() {
+ public void testNonInterpolatedMessageParameterIsUsed() {
Validator validator = TestUtil.getValidatorUnderTest();
Author author = new Author();
@@ -177,8 +180,10 @@
assertCorrectNumberOfViolations( constraintViolations, 1 );
ConstraintViolation<Author> constraintViolation = constraintViolations.iterator().next();
- assertEquals( constraintViolation.getMessage(), "The company name must be a minimum 3 characters" );
+ //commented we cannot make assumptions on the default locale.
+ //assertEquals( constraintViolation.getMessage(), "The company name must be a minimum 3 characters" );
assertEquals( constraintViolation.getMessageTemplate(), "The company name must be a minimum {min} characters" );
+ assertTrue( !constraintViolation.getMessageTemplate().equals( constraintViolation.getMessage() ) );
}
@Test
14 years, 8 months
Hibernate SVN: r17229 - in beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints: customconstraint and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2009-08-04 16:59:22 -0400 (Tue, 04 Aug 2009)
New Revision: 17229
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Author.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Positive.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java
Log:
Fix incorrect package name wrt the dir structure
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -31,6 +31,6 @@
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Documented
- @interface AlwaysValidList {
+@interface AlwaysValidList {
AlwaysValid[] value();
}
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Author.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Author.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Author.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import javax.validation.constraints.Size;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/BoundariesConstraintValidator.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import java.lang.annotation.Annotation;
import javax.validation.ConstraintValidator;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/CustomConstraintValidatorTest.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import java.util.Set;
import javax.validation.ConstraintViolation;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Negative.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import java.lang.annotation.Documented;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
@@ -39,5 +39,5 @@
public abstract Class<?>[] groups() default { };
- public abstract Class<? extends ConstraintPayload>[] payload() default {};
+ public abstract Class<? extends ConstraintPayload>[] payload() default { };
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/NegativeConstraintValidator.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Positive.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Positive.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/Positive.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
import java.lang.annotation.Documented;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
Modified: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java 2009-08-04 19:13:33 UTC (rev 17228)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/customconstraint/PositiveConstraintValidator.java 2009-08-04 20:59:22 UTC (rev 17229)
@@ -15,12 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.hibernate.jsr303.tck.tests.validation.customconstraint;
+package org.hibernate.jsr303.tck.tests.constraints.customconstraint;
/**
* @author Emmanuel Bernard
*/
-public class PositiveConstraintValidator extends BoundariesConstraintValidator<Positive> {
+public class PositiveConstraintValidator extends BoundariesConstraintValidator<Positive> {
public void initialize(Positive constraintAnnotation) {
super.initialize( 0, Integer.MAX_VALUE );
}
14 years, 8 months
Hibernate SVN: r17228 - core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-04 15:13:33 -0400 (Tue, 04 Aug 2009)
New Revision: 17228
Added:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImplementors.java
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
Log:
EJB-447 : Implement JPA 2.0 criteria apis
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -23,6 +23,7 @@
import javax.persistence.criteria.CollectionJoin;
import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Fetch;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.ListJoin;
@@ -42,7 +43,9 @@
*
* @author Steve Ebersole
*/
-public abstract class AbstractBasicPluralJoin<O,C,E> extends JoinImpl<O,E> implements PluralJoin<O,C,E> {
+public abstract class AbstractBasicPluralJoin<O,C,E>
+ extends JoinImpl<O,E>
+ implements PluralJoin<O,C,E>, Fetch<O,E> {
public AbstractBasicPluralJoin(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -21,7 +21,6 @@
*/
package org.hibernate.ejb.criteria;
-import javax.persistence.criteria.CollectionJoin;
import javax.persistence.criteria.JoinType;
import javax.persistence.metamodel.CollectionAttribute;
@@ -33,7 +32,7 @@
*/
public class BasicCollectionJoinImpl<O,E>
extends AbstractBasicPluralJoin<O,java.util.Collection<E>,E>
- implements CollectionJoin<O,E> {
+ implements JoinImplementors.CollectionJoinImplementor<O,E> {
public BasicCollectionJoinImpl(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -23,7 +23,6 @@
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.ListJoin;
import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.expression.ListIndexExpression;
@@ -35,7 +34,7 @@
*/
public class BasicListJoinImpl<O,E>
extends AbstractBasicPluralJoin<O,java.util.List<E>,E>
- implements ListJoin<O,E> {
+ implements JoinImplementors.ListJoinImplementor<O,E> {
public BasicListJoinImpl(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -26,7 +26,6 @@
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.Path;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.Type.PersistenceType;
@@ -43,7 +42,7 @@
*/
public class BasicMapJoinImpl<O,K,V>
extends AbstractBasicPluralJoin<O,java.util.Map<K,V>,V>
- implements MapJoin<O,K,V> {
+ implements JoinImplementors.MapJoinImplementor<O,K,V> {
public BasicMapJoinImpl(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -22,7 +22,6 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.SetJoin;
import javax.persistence.metamodel.SetAttribute;
/**
@@ -33,7 +32,7 @@
*/
public class BasicSetJoinImpl<O,E>
extends AbstractBasicPluralJoin<O,java.util.Set<E>,E>
- implements SetJoin<O,E> {
+ implements JoinImplementors.SetJoinImplementor<O,E> {
public BasicSetJoinImpl(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -21,7 +21,6 @@
*/
package org.hibernate.ejb.criteria;
-import javax.persistence.criteria.CollectionJoin;
import javax.persistence.criteria.JoinType;
import javax.persistence.metamodel.CollectionAttribute;
@@ -31,7 +30,9 @@
*
* @author Steve Ebersole
*/
-public class CollectionJoinImpl<O,E> extends JoinImpl<O,E> implements CollectionJoin<O,E> {
+public class CollectionJoinImpl<O,E>
+ extends JoinImpl<O,E>
+ implements JoinImplementors.CollectionJoinImplementor<O,E> {
public CollectionJoinImpl(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -124,10 +124,6 @@
return joins;
}
- protected void addJoin(Join<X,?> join) {
- getJoinsInternal().add( join );
- }
-
/**
* {@inheritDoc}
*/
@@ -139,6 +135,12 @@
* {@inheritDoc}
*/
public <Y> Join<X, Y> join(SingularAttribute<? super X, Y> attribute, JoinType jt) {
+ Join<X, Y> join = constructJoin( attribute, jt );
+ getJoinsInternal().add( join );
+ return join;
+ }
+
+ private <Y> JoinImplementors.JoinImplementor<X, Y> constructJoin(SingularAttribute<? super X, Y> attribute, JoinType jt) {
if ( PersistenceType.BASIC.equals( attribute.getType().getPersistenceType() ) ) {
throw new BasicPathUsageException( "Cannot join to attribute of basic type", attribute );
}
@@ -150,17 +152,14 @@
}
final Class<Y> attributeType = attribute.getBindableJavaType();
- final JoinImpl<X, Y> join = new JoinImpl<X, Y>(
+ return new JoinImpl<X, Y>(
queryBuilder(),
attributeType,
this,
attribute,
jt
);
- joins.add( join );
- return join;
}
-
/**
* {@inheritDoc}
*/
@@ -172,12 +171,18 @@
* {@inheritDoc}
*/
public <Y> CollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection, JoinType jt) {
+ final CollectionJoin<X, Y> join = constructJoin( collection, jt );
+ getJoinsInternal().add( join );
+ return join;
+ }
+
+ private <Y> JoinImplementors.CollectionJoinImplementor<X, Y> constructJoin(CollectionAttribute<? super X, Y> collection, JoinType jt) {
if ( jt.equals( JoinType.RIGHT ) ) {
throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
}
final Class<Y> attributeType = collection.getBindableJavaType();
- final CollectionJoin<X, Y> join;
+ final JoinImplementors.CollectionJoinImplementor<X, Y> join;
if ( isBasicCollection( collection ) ) {
join = new BasicCollectionJoinImpl<X, Y>(
queryBuilder(),
@@ -196,7 +201,6 @@
jt
);
}
- joins.add( join );
return join;
}
@@ -215,19 +219,24 @@
* {@inheritDoc}
*/
public <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set, JoinType jt) {
+ final SetJoin<X, Y> join = constructJoin( set, jt );
+ getJoinsInternal().add( join );
+ return join;
+ }
+
+ private <Y> JoinImplementors.SetJoinImplementor<X, Y> constructJoin(SetAttribute<? super X, Y> set, JoinType jt) {
if ( jt.equals( JoinType.RIGHT ) ) {
throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
}
final Class<Y> attributeType = set.getBindableJavaType();
- final SetJoin<X, Y> join;
+ final JoinImplementors.SetJoinImplementor<X, Y> join;
if ( isBasicCollection( set ) ) {
join = new BasicSetJoinImpl<X, Y>( queryBuilder(), attributeType, this, set, jt );
}
else {
join = new SetJoinImpl<X, Y>( queryBuilder(), attributeType, this, set, jt );
}
- joins.add( join );
return join;
}
@@ -242,19 +251,24 @@
* {@inheritDoc}
*/
public <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list, JoinType jt) {
+ final ListJoin<X, Y> join = constructJoin( list, jt );
+ getJoinsInternal().add( join );
+ return join;
+ }
+
+ private <Y> JoinImplementors.ListJoinImplementor<X, Y> constructJoin(ListAttribute<? super X, Y> list, JoinType jt) {
if ( jt.equals( JoinType.RIGHT ) ) {
throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
}
final Class<Y> attributeType = list.getBindableJavaType();
- final ListJoin<X, Y> join;
+ final JoinImplementors.ListJoinImplementor<X, Y> join;
if ( isBasicCollection( list ) ) {
join = new BasicListJoinImpl<X, Y>( queryBuilder(), attributeType, this, list, jt );
}
else {
join = new ListJoinImpl<X, Y>( queryBuilder(), attributeType, this, list, jt );
}
- joins.add( join );
return join;
}
@@ -269,19 +283,24 @@
* {@inheritDoc}
*/
public <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map, JoinType jt) {
+ final MapJoin<X, K, V> join = constructJoin( map, jt );
+ getJoinsInternal().add( join );
+ return join;
+ }
+
+ private <K, V> JoinImplementors.MapJoinImplementor<X, K, V> constructJoin(MapAttribute<? super X, K, V> map, JoinType jt) {
if ( jt.equals( JoinType.RIGHT ) ) {
throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
}
final Class<V> attributeType = map.getBindableJavaType();
- final MapJoin<X, K, V> join;
+ final JoinImplementors.MapJoinImplementor<X, K, V> join;
if ( isBasicCollection( map ) ) {
join = new BasicMapJoinImpl<X,K,V>( queryBuilder(), attributeType, this, map, jt );
}
else {
join = new MapJoinImpl<X,K,V>( queryBuilder(), attributeType, this, map, jt );
}
- joins.add( join );
return join;
}
@@ -444,9 +463,10 @@
return fetch( singularAttribute, DEFAULT_JOIN_TYPE );
}
- public <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> singularAttribute, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ public <Y> Fetch<X, Y> fetch(SingularAttribute<? super X, Y> attribute, JoinType jt) {
+ Fetch<X, Y> fetch = constructJoin( attribute, jt );
+ getFetchesInternal().add( fetch );
+ return fetch;
}
public <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> pluralAttribute) {
@@ -454,8 +474,22 @@
}
public <Y> Fetch<X, Y> fetch(PluralAttribute<? super X, ?, Y> pluralAttribute, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ final Fetch<X, Y> fetch;
+ // TODO : combine Fetch and Join hierarchies (JoinImplementor extends Join,Fetch???)
+ if ( CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
+ fetch = constructJoin( (CollectionAttribute<X,Y>) pluralAttribute, jt );
+ }
+ else if ( CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
+ fetch = constructJoin( (ListAttribute<X,Y>) pluralAttribute, jt );
+ }
+ else if ( CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
+ fetch = constructJoin( (SetAttribute<X,Y>) pluralAttribute, jt );
+ }
+ else {
+ fetch = constructJoin( (MapAttribute<X,?,Y>) pluralAttribute, jt );
+ }
+ getFetchesInternal().add( fetch );
+ return fetch;
}
public <Y> Fetch<X, Y> fetch(String attributeName) {
@@ -463,8 +497,13 @@
}
public <Y> Fetch<X, Y> fetch(String attributeName, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ Attribute<X,?> attribute = getAttribute( attributeName );
+ if ( attribute.isCollection() ) {
+ return fetch( (PluralAttribute<X,?,Y>)attribute, jt );
+ }
+ else {
+ return fetch( (SingularAttribute<X,Y>) attribute, jt );
+ }
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -22,7 +22,6 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.From;
-import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.ManagedType;
@@ -32,7 +31,7 @@
*
* @author Steve Ebersole
*/
-public class JoinImpl<Z, X> extends FromImpl<Z, X> implements Join<Z, X> {
+public class JoinImpl<Z, X> extends FromImpl<Z, X> implements JoinImplementors.JoinImplementor<Z,X> {
// TODO : keep track or whether any non-identifier properties get dereferenced
// for join optimization like in HQL
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImplementors.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImplementors.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImplementors.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -0,0 +1,52 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.CollectionJoin;
+import javax.persistence.criteria.Fetch;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.ListJoin;
+import javax.persistence.criteria.MapJoin;
+import javax.persistence.criteria.SetJoin;
+
+/**
+ * Consolidates the {@link Join} and {@link Fetch} hierarchies since that is how we implement them.
+ * This allows us to treat them polymorphically.
+ *
+ * @author Steve Ebersole
+ */
+public interface JoinImplementors {
+ public static interface JoinImplementor<Z,X> extends Join<Z,X>, Fetch<Z,X> {
+ }
+
+ public static interface CollectionJoinImplementor<Z,X> extends CollectionJoin<Z,X>, Fetch<Z,X> {
+ }
+
+ public static interface SetJoinImplementor<Z,X> extends SetJoin<Z,X>, Fetch<Z,X> {
+ }
+
+ public static interface ListJoinImplementor<Z,X> extends ListJoin<Z,X>, Fetch<Z,X> {
+ }
+
+ public static interface MapJoinImplementor<Z,K,V> extends MapJoin<Z,K,V>, Fetch<Z,V> {
+ }
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -23,7 +23,6 @@
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.ListJoin;
import javax.persistence.metamodel.ListAttribute;
import org.hibernate.ejb.criteria.expression.ListIndexExpression;
@@ -33,7 +32,7 @@
*
* @author Steve Ebersole
*/
-public class ListJoinImpl<O,E> extends JoinImpl<O,E> implements ListJoin<O,E> {
+public class ListJoinImpl<O,E> extends JoinImpl<O,E> implements JoinImplementors.ListJoinImplementor<O,E> {
public ListJoinImpl(
QueryBuilderImpl queryBuilder,
Class<E> javaType,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -26,7 +26,6 @@
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.MapJoin;
import javax.persistence.criteria.Path;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.Type.PersistenceType;
@@ -39,7 +38,7 @@
*/
public class MapJoinImpl<O,K,V>
extends JoinImpl<O,V>
- implements MapJoin<O,K,V> {
+ implements JoinImplementors.MapJoinImplementor<O,K,V> {
public MapJoinImpl(
QueryBuilderImpl queryBuilder,
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java 2009-08-04 19:13:33 UTC (rev 17228)
@@ -22,7 +22,6 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.JoinType;
-import javax.persistence.criteria.SetJoin;
import javax.persistence.metamodel.SetAttribute;
/**
@@ -31,7 +30,10 @@
*
* @author Steve Ebersole
*/
-public class SetJoinImpl<O,E> extends JoinImpl<O,E> implements SetJoin<O,E> {
+public class SetJoinImpl<O,E>
+ extends JoinImpl<O,E>
+ implements JoinImplementors.SetJoinImplementor<O,E> {
+
public SetJoinImpl(
QueryBuilderImpl queryBuilder,
Class<E> javaType,
14 years, 8 months
Hibernate SVN: r17227 - in core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria: expression and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-04 14:01:45 -0400 (Tue, 04 Aug 2009)
New Revision: 17227
Added:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicPathUsageException.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AverageAggregrateFunction.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SumAggregateFunction.java
Removed:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractExpression.java
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryBuilderImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/FunctionExpressionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java
Log:
EJB-447 : Implement JPA 2.0 criteria apis
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/AbstractBasicPluralJoin.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,144 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.CollectionJoin;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.ListJoin;
+import javax.persistence.criteria.MapJoin;
+import javax.persistence.criteria.Path;
+import javax.persistence.criteria.PluralJoin;
+import javax.persistence.criteria.SetJoin;
+import javax.persistence.metamodel.CollectionAttribute;
+import javax.persistence.metamodel.ListAttribute;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+
+/**
+ * Convenience base class for all basic collection joins. Mainly we handle the fact that
+ * this path cannot be further de-referenced.
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractBasicPluralJoin<O,C,E> extends JoinImpl<O,E> implements PluralJoin<O,C,E> {
+
+ public AbstractBasicPluralJoin(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ PluralAttribute<? super O, ?, ?> joinProperty,
+ JoinType joinType) {
+ super(queryBuilder, javaType, lhs, joinProperty, joinType);
+ }
+
+ @Override
+ public PluralAttribute<? super O, C, E> getModel() {
+ return ( PluralAttribute<? super O, C, E> ) super.getAttribute();
+ }
+
+ @Override
+ public Expression<Class<? extends E>> type(){
+ throw new BasicPathUsageException( "type() is not applicable to primitive paths.", getAttribute() );
+ }
+
+ @Override
+ public <Y> Path<Y> get(SingularAttribute<? super E, Y> attribute){
+ throw illegalDereference();
+ }
+
+ private BasicPathUsageException illegalDereference() {
+ return new BasicPathUsageException( "Basic collection elements cannot be de-referenced", getAttribute() );
+ }
+
+ @Override
+ public <Y, C extends java.util.Collection<Y>> Expression<C> get(PluralAttribute<E, C, Y> collection){
+ throw illegalDereference();
+ }
+
+ @Override
+ public <L, W, M extends java.util.Map<L, W>> Expression<M> get(MapAttribute<E, L, W> map){
+ throw illegalDereference();
+ }
+
+ @Override
+ public <Y> Path<Y> get(String attName) {
+ throw illegalDereference();
+ }
+
+ @Override
+ public <Y> Join<E, Y> join(SingularAttribute<? super E, Y> attribute, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ private BasicPathUsageException illegalJoin() {
+ return new BasicPathUsageException( "Basic collection cannot be source of a join", getAttribute() );
+ }
+
+ @Override
+ public <Y> CollectionJoin<E, Y> join(CollectionAttribute<? super E, Y> collection, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <Y> SetJoin<E, Y> join(javax.persistence.metamodel.SetAttribute<? super E, Y> set, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <Y> ListJoin<E, Y> join(ListAttribute<? super E, Y> list, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <L, W> MapJoin<E, L, W> join(MapAttribute<? super E, L, W> map, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <Y> Join<E, Y> join(String attributeName, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <Y> CollectionJoin<E, Y> joinCollection(String attributeName, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <Y> ListJoin<E, Y> joinList(String attributeName, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <L, W> MapJoin<E, L, W> joinMap(String attributeName, JoinType jt) {
+ throw illegalJoin();
+ }
+
+ @Override
+ public <Y> SetJoin<E, Y> joinSet(String attributeName, JoinType jt) {
+ throw illegalJoin();
+ }
+
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicCollectionJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,52 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.CollectionJoin;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.metamodel.CollectionAttribute;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.Collection}, whose elements
+ * are basic type.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicCollectionJoinImpl<O,E>
+ extends AbstractBasicPluralJoin<O,java.util.Collection<E>,E>
+ implements CollectionJoin<O,E> {
+
+ public BasicCollectionJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ CollectionAttribute<? super O, E> joinProperty,
+ JoinType joinType) {
+ super(queryBuilder, javaType, lhs, joinProperty, joinType);
+ }
+
+ @Override
+ public CollectionAttribute<? super O, E> getModel() {
+ return (CollectionAttribute<? super O, E>) super.getAttribute();
+ }
+
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicListJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,62 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.ListJoin;
+import javax.persistence.metamodel.ListAttribute;
+import org.hibernate.ejb.criteria.expression.ListIndexExpression;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.List}, whose elements
+ * are basic type.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicListJoinImpl<O,E>
+ extends AbstractBasicPluralJoin<O,java.util.List<E>,E>
+ implements ListJoin<O,E> {
+
+ public BasicListJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ ListAttribute<? super O, ?> joinProperty,
+ JoinType joinType) {
+ super(queryBuilder, javaType, lhs, joinProperty, joinType);
+ }
+
+ @Override
+ public ListAttribute<? super O, E> getAttribute() {
+ return (ListAttribute<? super O, E>) super.getAttribute();
+ }
+
+ @Override
+ public ListAttribute<? super O, E> getModel() {
+ return getAttribute();
+ }
+
+ public Expression<Integer> index() {
+ return new ListIndexExpression( queryBuilder(), getAttribute() );
+ }
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicMapJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,137 @@
+/*
+ * 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.ejb.criteria;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.MapJoin;
+import javax.persistence.criteria.Path;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.Type.PersistenceType;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.Map}, whose elements
+ * are associations.
+ *
+ * @param <O> The map owner
+ * @param <K> The map key
+ * @param <V> The map value
+ *
+ * @author Steve Ebersole
+ */
+public class BasicMapJoinImpl<O,K,V>
+ extends AbstractBasicPluralJoin<O,java.util.Map<K,V>,V>
+ implements MapJoin<O,K,V> {
+
+ public BasicMapJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<V> javaType,
+ PathImpl<O> lhs,
+ MapAttribute<? super O, K, V> joinProperty,
+ JoinType joinType) {
+ super( queryBuilder, javaType, lhs, joinProperty, joinType );
+ }
+
+ @Override
+ public MapAttribute<? super O, K, V> getAttribute() {
+ return (MapAttribute<? super O, K, V>) super.getAttribute();
+ }
+
+ @Override
+ public MapAttribute<? super O, K, V> getModel() {
+ return getAttribute();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Join<Map<K, V>, K> joinKey() {
+ return joinKey( DEFAULT_JOIN_TYPE );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Join<Map<K, V>, K> joinKey(JoinType jt) {
+ if ( PersistenceType.BASIC.equals( getAttribute().getKeyType().getPersistenceType() ) ) {
+ throw new BasicPathUsageException( "Cannot join to map key of basic type", getAttribute() );
+ }
+
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final MapKeyHelpers.MapPath<K,V> source = new MapKeyHelpers.MapPath<K,V>(
+ queryBuilder(),
+ getAttribute().getJavaType(),
+ this,
+ getAttribute(),
+ getParentPath().getModel()
+ );
+ final MapKeyHelpers.MapKeyAttribute attribute = new MapKeyHelpers.MapKeyAttribute( queryBuilder(), getAttribute() );
+ final Join<Map<K, V>, K> join = new MapKeyHelpers.MapKeyJoin<K,V>(
+ queryBuilder(),
+ source,
+ attribute,
+ jt
+ );
+
+ return join;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @SuppressWarnings({ "unchecked" })
+ public Path<K> key() {
+ final MapKeyHelpers.MapPath<K,V> source = new MapKeyHelpers.MapPath<K,V>(
+ queryBuilder(),
+ getAttribute().getJavaType(),
+ this,
+ getAttribute(),
+ getParentPath().getModel()
+ );
+ final MapKeyHelpers.MapKeyAttribute attribute = new MapKeyHelpers.MapKeyAttribute( queryBuilder(), getAttribute() );
+ return new MapKeyHelpers.MapKeyPath( queryBuilder(), source, attribute );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Path<V> value() {
+ // API docs explicitly say value() should simply return this;
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Expression<Entry<K, V>> entry() {
+ // TODO : ???
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicPathUsageException.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicPathUsageException.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicPathUsageException.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,61 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.metamodel.Attribute;
+
+/**
+ * Represents an incorrect usage of a basic path. Generally this means an attempt to
+ * de-reference a basic attribute path.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicPathUsageException extends RuntimeException {
+ private final Attribute<?,?> attribute;
+
+ /**
+ * Construct the usage exception.
+ *
+ * @param message An error message describing the incorrect usage.
+ * @param attribute The basic attribute involved.
+ */
+ public BasicPathUsageException(String message, Attribute<?,?> attribute) {
+ super( message );
+ this.attribute = attribute;
+ }
+
+ /**
+ * Construct the usage exception.
+ *
+ * @param message An error message describing the incorrect usage.
+ * @param cause An underlying cause.
+ * @param attribute The basic attribute involved.
+ */
+ public BasicPathUsageException(String message, Throwable cause, Attribute<?,?> attribute) {
+ super( message, cause );
+ this.attribute = attribute;
+ }
+
+ public Attribute<?,?> getAttribute() {
+ return attribute;
+ }
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/BasicSetJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,51 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.SetJoin;
+import javax.persistence.metamodel.SetAttribute;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.Set}, whose elements
+ * are basic type.
+ *
+ * @author Steve Ebersole
+ */
+public class BasicSetJoinImpl<O,E>
+ extends AbstractBasicPluralJoin<O,java.util.Set<E>,E>
+ implements SetJoin<O,E> {
+
+ public BasicSetJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ SetAttribute<? super O, ?> joinProperty,
+ JoinType joinType) {
+ super( queryBuilder, javaType, lhs, joinProperty, joinType );
+ }
+
+ @Override
+ public SetAttribute<? super O, E> getModel() {
+ return (SetAttribute<? super O, E>) super.getAttribute();
+ }
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CollectionJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,50 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.CollectionJoin;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.metamodel.CollectionAttribute;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.Collection}, whose elements
+ * are associations.
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionJoinImpl<O,E> extends JoinImpl<O,E> implements CollectionJoin<O,E> {
+
+ public CollectionJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ CollectionAttribute<? super O, ?> joinProperty,
+ JoinType joinType) {
+ super(queryBuilder, javaType, lhs, joinProperty, joinType);
+ }
+
+ @Override
+ public CollectionAttribute<? super O, E> getModel() {
+ return (CollectionAttribute<? super O, E>) super.getAttribute();
+ }
+
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/CriteriaSubqueryImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -34,14 +34,14 @@
import javax.persistence.criteria.SetJoin;
import javax.persistence.criteria.Subquery;
import javax.persistence.metamodel.EntityType;
-import org.hibernate.ejb.criteria.expression.AbstractExpression;
+import org.hibernate.ejb.criteria.expression.ExpressionImpl;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
-public class CriteriaSubqueryImpl<T> extends AbstractExpression<T> implements Subquery<T> {
+public class CriteriaSubqueryImpl<T> extends ExpressionImpl<T> implements Subquery<T> {
private final AbstractQuery<?> parent;
private final QueryStructure<T> queryStructure;
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/FromImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -36,18 +36,19 @@
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Fetch;
import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Attribute.PersistentAttributeType;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.SetAttribute;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.MapAttribute;
-import javax.persistence.metamodel.Bindable;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.PluralAttribute;
+import javax.persistence.metamodel.PluralAttribute.CollectionType;
import javax.persistence.metamodel.Type.PersistenceType;
-import org.hibernate.ejb.criteria.expression.AbstractExpression;
+import org.hibernate.ejb.criteria.expression.CollectionExpression;
import org.hibernate.ejb.criteria.expression.EntityTypeExpression;
/**
@@ -69,7 +70,7 @@
* @param entityType
*/
protected FromImpl(QueryBuilderImpl queryBuilder, EntityType<X> entityType) {
- super( queryBuilder, entityType.getBindableJavaType(), null, entityType );
+ super( queryBuilder, entityType.getBindableJavaType(), null, null, entityType );
this.type = new EntityTypeExpression( queryBuilder, entityType.getBindableJavaType() );
}
@@ -77,10 +78,10 @@
QueryBuilderImpl queryBuilder,
Class<X> javaType,
PathImpl<Z> origin,
- Bindable<X> model,
- Expression<Class<? extends X>> type) {
- super( queryBuilder, javaType, origin, model );
- this.type = type;
+ Attribute<? super Z, ?> attribute,
+ ManagedType<X> model) {
+ super( queryBuilder, javaType, origin, attribute, model );
+ this.type = new EntityTypeExpression( queryBuilder, model.getJavaType() );
}
@Override
@@ -88,7 +89,19 @@
return type;
}
+ /**
+ * Get the attribute by name from the underlying model. This alows subclasses to
+ * define exactly how the attribute is derived.
+ *
+ * @param name The attribute name
+ *
+ * @return The attribute.
+ *
+ * @throws IllegalArgumentException If no such attribute is found (follows exception type from {@link ManagedType}).
+ */
+ protected abstract Attribute<X,?> getAttribute(String name);
+
// JOINS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
@@ -111,6 +124,10 @@
return joins;
}
+ protected void addJoin(Join<X,?> join) {
+ getJoinsInternal().add( join );
+ }
+
/**
* {@inheritDoc}
*/
@@ -123,9 +140,25 @@
*/
public <Y> Join<X, Y> join(SingularAttribute<? super X, Y> attribute, JoinType jt) {
if ( PersistenceType.BASIC.equals( attribute.getType().getPersistenceType() ) ) {
- throw new IllegalStateException( "Cannot join to basic type" );
+ throw new BasicPathUsageException( "Cannot join to attribute of basic type", attribute );
}
- throw new UnsupportedOperationException( "Not yet implemented!" );
+
+ // TODO : runtime check that the attribute in fact belongs to this From's model/bindable
+
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final Class<Y> attributeType = attribute.getBindableJavaType();
+ final JoinImpl<X, Y> join = new JoinImpl<X, Y>(
+ queryBuilder(),
+ attributeType,
+ this,
+ attribute,
+ jt
+ );
+ joins.add( join );
+ return join;
}
/**
@@ -139,10 +172,38 @@
* {@inheritDoc}
*/
public <Y> CollectionJoin<X, Y> join(CollectionAttribute<? super X, Y> collection, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final Class<Y> attributeType = collection.getBindableJavaType();
+ final CollectionJoin<X, Y> join;
+ if ( isBasicCollection( collection ) ) {
+ join = new BasicCollectionJoinImpl<X, Y>(
+ queryBuilder(),
+ attributeType,
+ this,
+ collection,
+ jt
+ );
+ }
+ else {
+ join = new CollectionJoinImpl<X, Y>(
+ queryBuilder(),
+ attributeType,
+ this,
+ collection,
+ jt
+ );
+ }
+ joins.add( join );
+ return join;
}
+ private boolean isBasicCollection(PluralAttribute collection) {
+ return PersistenceType.BASIC.equals( collection.getElementType().getPersistenceType() );
+ }
+
/**
* {@inheritDoc}
*/
@@ -154,8 +215,20 @@
* {@inheritDoc}
*/
public <Y> SetJoin<X, Y> join(SetAttribute<? super X, Y> set, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final Class<Y> attributeType = set.getBindableJavaType();
+ final SetJoin<X, Y> join;
+ if ( isBasicCollection( set ) ) {
+ join = new BasicSetJoinImpl<X, Y>( queryBuilder(), attributeType, this, set, jt );
+ }
+ else {
+ join = new SetJoinImpl<X, Y>( queryBuilder(), attributeType, this, set, jt );
+ }
+ joins.add( join );
+ return join;
}
/**
@@ -169,8 +242,20 @@
* {@inheritDoc}
*/
public <Y> ListJoin<X, Y> join(ListAttribute<? super X, Y> list, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final Class<Y> attributeType = list.getBindableJavaType();
+ final ListJoin<X, Y> join;
+ if ( isBasicCollection( list ) ) {
+ join = new BasicListJoinImpl<X, Y>( queryBuilder(), attributeType, this, list, jt );
+ }
+ else {
+ join = new ListJoinImpl<X, Y>( queryBuilder(), attributeType, this, list, jt );
+ }
+ joins.add( join );
+ return join;
}
/**
@@ -184,83 +269,152 @@
* {@inheritDoc}
*/
public <K, V> MapJoin<X, K, V> join(MapAttribute<? super X, K, V> map, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final Class<V> attributeType = map.getBindableJavaType();
+ final MapJoin<X, K, V> join;
+ if ( isBasicCollection( map ) ) {
+ join = new BasicMapJoinImpl<X,K,V>( queryBuilder(), attributeType, this, map, jt );
+ }
+ else {
+ join = new MapJoinImpl<X,K,V>( queryBuilder(), attributeType, this, map, jt );
+ }
+ joins.add( join );
+ return join;
}
/**
* {@inheritDoc}
*/
- public <X, Y> Join<X, Y> join(String attributeName) {
+ public <Y> Join<X, Y> join(String attributeName) {
return join( attributeName, DEFAULT_JOIN_TYPE );
}
/**
* {@inheritDoc}
*/
- public <X, Y> Join<X, Y> join(String attributeName, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ public <Y> Join<X, Y> join(String attributeName, JoinType jt) {
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
+ if ( attribute.isCollection() ) {
+ final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute;
+ if ( CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
+ return join( (CollectionAttribute<X,Y>) attribute, jt );
+ }
+ else if ( CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
+ return join( (ListAttribute<X,Y>) attribute, jt );
+ }
+ else if ( CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
+ return join( (SetAttribute<X,Y>) attribute, jt );
+ }
+ else {
+ return join( (MapAttribute<X,?,Y>) attribute, jt );
+ }
+ }
+ else {
+ return join( (SingularAttribute)attribute, jt );
+ }
}
/**
* {@inheritDoc}
*/
- public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName) {
+ public <Y> CollectionJoin<X, Y> joinCollection(String attributeName) {
return joinCollection( attributeName, DEFAULT_JOIN_TYPE );
}
/**
* {@inheritDoc}
*/
- public <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ public <Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt) {
+ final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
+ if ( ! attribute.isCollection() ) {
+ throw new IllegalArgumentException( "Requested attribute was not a collection" );
+ }
+
+ final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute;
+ if ( ! CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
+ throw new IllegalArgumentException( "Requested attribute was not a collection" );
+ }
+
+ return join( (CollectionAttribute<X,Y>) attribute, jt );
}
/**
* {@inheritDoc}
*/
- public <X, Y> SetJoin<X, Y> joinSet(String attributeName) {
+ public <Y> SetJoin<X, Y> joinSet(String attributeName) {
return joinSet( attributeName, DEFAULT_JOIN_TYPE );
}
/**
* {@inheritDoc}
*/
- public <X, Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ public <Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt) {
+ final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
+ if ( ! attribute.isCollection() ) {
+ throw new IllegalArgumentException( "Requested attribute was not a set" );
+ }
+
+ final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute;
+ if ( ! CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
+ throw new IllegalArgumentException( "Requested attribute was not a set" );
+ }
+
+ return join( (SetAttribute<X,Y>) attribute, jt );
}
/**
* {@inheritDoc}
*/
- public <X, Y> ListJoin<X, Y> joinList(String attributeName) {
+ public <Y> ListJoin<X, Y> joinList(String attributeName) {
return joinList( attributeName, DEFAULT_JOIN_TYPE );
}
/**
* {@inheritDoc}
*/
- public <X, Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ public <Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt) {
+ final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
+ if ( ! attribute.isCollection() ) {
+ throw new IllegalArgumentException( "Requested attribute was not a list" );
+ }
+
+ final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute;
+ if ( ! CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
+ throw new IllegalArgumentException( "Requested attribute was not a list" );
+ }
+
+ return join( (ListAttribute<X,Y>) attribute, jt );
}
/**
* {@inheritDoc}
*/
- public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName) {
+ public <K, V> MapJoin<X, K, V> joinMap(String attributeName) {
return joinMap( attributeName, DEFAULT_JOIN_TYPE );
}
/**
* {@inheritDoc}
*/
- public <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ public <K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt) {
+ final Attribute<X,?> attribute = (Attribute<X, ?>) getAttribute( attributeName );
+ if ( ! attribute.isCollection() ) {
+ throw new IllegalArgumentException( "Requested attribute was not a map" );
+ }
+
+ final PluralAttribute pluralAttribute = ( PluralAttribute ) attribute;
+ if ( ! CollectionType.MAP.equals( pluralAttribute.getCollectionType() ) ) {
+ throw new IllegalArgumentException( "Requested attribute was not a map" );
+ }
+
+ return join( (MapAttribute<X,K,V>) attribute, jt );
}
@@ -316,23 +470,46 @@
// PATH HANDLING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- public <Y> Path<Y> get(SingularAttribute<? super X, Y> ySingularAttribute) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ @Override
+ public <Y> Path<Y> get(SingularAttribute<? super X, Y> attribute) {
+ if ( PersistentAttributeType.BASIC.equals( attribute.getPersistentAttributeType() ) ) {
+ return new PathImpl<Y>( queryBuilder(), attribute.getJavaType(), this, attribute, attribute.getBindableType() );
+ }
+ else {
+ return join( attribute );
+ }
}
+ @Override
public <E, C extends Collection<E>> Expression<C> get(PluralAttribute<X, C, E> collection) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ return new CollectionExpression<C>( queryBuilder(), collection.getJavaType(), collection );
}
+ @Override
public <K, V, M extends Map<K, V>> Expression<M> get(MapAttribute<X, K, V> map) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ return ( Expression<M> ) new CollectionExpression<Map<K, V>>( queryBuilder(), map.getJavaType(), map );
}
+ @Override
public <Y> Path<Y> get(String attributeName) {
- // TODO : implement
- throw new UnsupportedOperationException( "Not yet implemented!" );
+ Attribute attribute = getAttribute( attributeName );
+ if ( attribute.isCollection() ) {
+ final PluralAttribute<X,?,Y> pluralAttribute = (PluralAttribute<X, ?, Y>) attribute;
+ if ( CollectionType.COLLECTION.equals( pluralAttribute.getCollectionType() ) ) {
+ return join( (CollectionAttribute<X,Y>) attribute );
+ }
+ else if ( CollectionType.LIST.equals( pluralAttribute.getCollectionType() ) ) {
+ return join( (ListAttribute<X,Y>) attribute );
+ }
+ else if ( CollectionType.SET.equals( pluralAttribute.getCollectionType() ) ) {
+ return join( (SetAttribute<X,Y>) attribute );
+ }
+ else {
+ return join( (MapAttribute<X,?,Y>) attribute );
+ }
+ }
+ else {
+ return get( (SingularAttribute<X,Y>) attribute );
+ }
}
}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/JoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,87 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.From;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.ManagedType;
+
+/**
+ * Models a non-collection property join.
+ *
+ * @author Steve Ebersole
+ */
+public class JoinImpl<Z, X> extends FromImpl<Z, X> implements Join<Z, X> {
+ // TODO : keep track or whether any non-identifier properties get dereferenced
+ // for join optimization like in HQL
+
+ // TODO : do we need (or is it easier with) a separate "component join impl"?
+
+ // TODO : cleanup these ctors, ugh...
+
+ private final ManagedType<X> managedType;
+ private final JoinType joinType;
+
+ public JoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<X> javaType,
+ PathImpl<Z> lhs,
+ Attribute<? super Z, ?> joinProperty,
+ JoinType joinType) {
+ super(
+ queryBuilder,
+ javaType,
+ lhs,
+ joinProperty,
+ (ManagedType<X>)queryBuilder.getEntityManagerFactory().getMetamodel().type( javaType )
+ );
+ this.managedType = (ManagedType<X>) getModel();
+ this.joinType = joinType;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public From<?, Z> getParent() {
+ // AFAICT, only "froms" (specifically roots and joins) can be the parent of a join.
+ return ( From<?, Z> ) getParentPath();
+ }
+
+ @Override
+ public Attribute<? super Z, ?> getAttribute() {
+ return (Attribute<? super Z, ?>) super.getAttribute();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public JoinType getJoinType() {
+ return joinType;
+ }
+
+ @Override
+ protected Attribute<X, ?> getAttribute(String name) {
+ return (Attribute<X, ?>) managedType.getAttribute( name );
+ }
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/ListJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,59 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.ListJoin;
+import javax.persistence.metamodel.ListAttribute;
+import org.hibernate.ejb.criteria.expression.ListIndexExpression;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.List}, whose elements
+ * are associations.
+ *
+ * @author Steve Ebersole
+ */
+public class ListJoinImpl<O,E> extends JoinImpl<O,E> implements ListJoin<O,E> {
+ public ListJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ ListAttribute<? super O, ?> joinProperty,
+ JoinType joinType) {
+ super( queryBuilder, javaType, lhs, joinProperty, joinType );
+ }
+
+ @Override
+ public ListAttribute<? super O, E> getAttribute() {
+ return (ListAttribute<? super O, E>) super.getAttribute();
+ }
+
+ @Override
+ public ListAttribute<? super O, E> getModel() {
+ return (ListAttribute<? super O, E>) getAttribute();
+ }
+
+ public Expression<Integer> index() {
+ return new ListIndexExpression( queryBuilder(), getAttribute() );
+ }
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,130 @@
+/*
+ * 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.ejb.criteria;
+
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.MapJoin;
+import javax.persistence.criteria.Path;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.Type.PersistenceType;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.Map}, whose elements
+ * are associations.
+ *
+ * @author Steve Ebersole
+ */
+public class MapJoinImpl<O,K,V>
+ extends JoinImpl<O,V>
+ implements MapJoin<O,K,V> {
+
+ public MapJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<V> javaType,
+ PathImpl<O> lhs,
+ MapAttribute<? super O, K, V> joinProperty,
+ JoinType joinType) {
+ super(queryBuilder, javaType, lhs, joinProperty, joinType);
+ }
+
+ @Override
+ public MapAttribute<? super O, K, V> getAttribute() {
+ return (MapAttribute<? super O, K, V>) super.getAttribute();
+ }
+
+ @Override
+ public MapAttribute<? super O, K, V> getModel() {
+ return getAttribute();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Join<Map<K, V>, K> joinKey() {
+ return joinKey( DEFAULT_JOIN_TYPE );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Join<Map<K, V>, K> joinKey(JoinType jt) {
+ if ( PersistenceType.BASIC.equals( getAttribute().getKeyType().getPersistenceType() ) ) {
+ throw new BasicPathUsageException( "Cannot join to map key of basic type", getAttribute() );
+ }
+
+ if ( jt.equals( JoinType.RIGHT ) ) {
+ throw new UnsupportedOperationException( "RIGHT JOIN not supported" );
+ }
+
+ final MapKeyHelpers.MapPath<K,V> mapKeySource = new MapKeyHelpers.MapPath<K,V>(
+ queryBuilder(),
+ getAttribute().getJavaType(),
+ this,
+ getAttribute(),
+ getParentPath().getModel()
+ );
+ final MapKeyHelpers.MapKeyAttribute mapKeyAttribute = new MapKeyHelpers.MapKeyAttribute( queryBuilder(), getAttribute() );
+ final Join<Map<K, V>, K> join = new MapKeyHelpers.MapKeyJoin<K,V>(
+ queryBuilder(),
+ mapKeySource,
+ mapKeyAttribute,
+ jt
+ );
+
+ return join;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Path<K> key() {
+ final MapKeyHelpers.MapPath<K,V> mapKeySource = new MapKeyHelpers.MapPath<K,V>(
+ queryBuilder(),
+ getAttribute().getJavaType(),
+ this,
+ getAttribute(),
+ getParentPath().getModel()
+ );
+ final MapKeyHelpers.MapKeyAttribute mapKeyAttribute = new MapKeyHelpers.MapKeyAttribute( queryBuilder(), getAttribute() );
+ return new MapKeyHelpers.MapKeyPath( queryBuilder(), mapKeySource, mapKeyAttribute );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Path<V> value() {
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Expression<Entry<K, V>> entry() {
+ // TODO : ???
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/MapKeyHelpers.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,246 @@
+/*
+ * 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.ejb.criteria;
+
+import java.lang.reflect.Member;
+import java.util.Map;
+import javax.persistence.criteria.Join;
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.MapJoin;
+import javax.persistence.criteria.Path;
+import javax.persistence.metamodel.Attribute;
+import javax.persistence.metamodel.Bindable.BindableType;
+import javax.persistence.metamodel.ManagedType;
+import javax.persistence.metamodel.MapAttribute;
+import javax.persistence.metamodel.SingularAttribute;
+import javax.persistence.metamodel.Type.PersistenceType;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.Type;
+
+/**
+ * {@link MapJoin} defines a number of methods which require {@link Path}, {@link Join} and {@link Attribute}
+ * implementations which do not fit nicely into the generic signatures it defines for everything else (mainly
+ * in terms of dealing with the map key). The implementations found here provide that bridge.
+ *
+ * @author Steve Ebersole
+ */
+public class MapKeyHelpers {
+
+ /**
+ * Represents a join to the key of a map attribute. Obviously the map key must be an
+ * entity or component type.
+ *
+ * @param <K> The type of the map key
+ * @param <V> The type of the map value
+ */
+ public static class MapKeyJoin<K,V> extends JoinImpl<Map<K, V>, K> implements Join<Map<K, V>, K> {
+ public MapKeyJoin(QueryBuilderImpl queryBuilder, MapPath<K,V> source, MapKeyAttribute<K> attribute, JoinType jt) {
+ super(
+ queryBuilder,
+ attribute.getJavaType(),
+ source,
+ attribute,
+ jt
+ );
+ }
+ }
+
+ /**
+ * Models a path to a map key.
+ *
+ * @param <K> The type of the map key.
+ */
+ public static class MapKeyPath<K> extends PathImpl<K> implements Path<K> {
+ public MapKeyPath(
+ QueryBuilderImpl queryBuilder,
+ MapPath<K,?> source,
+ MapKeyAttribute<K> attribute) {
+ super( queryBuilder, attribute.getJavaType(), source, attribute, attribute.getType() );
+ }
+ }
+
+ /**
+ * Defines a {@link Path} resulting in a map attribute. This can then be used as the
+ * parent/origin/source for referencing the map-key.
+ *
+ * @param <K> The map key type
+ * @param <V> The map value type
+ */
+ public static class MapPath<K,V> extends PathImpl<Map<K, V>> implements Path<Map<K, V>> {
+ private final MapJoin<?,K,V> mapJoin;
+
+ public MapPath(
+ QueryBuilderImpl queryBuilder,
+ Class<Map<K, V>> javaType,
+ MapJoin<?,K,V> mapJoin,
+ MapAttribute<?,K,V> attribute,
+ Object model) {
+ super(queryBuilder, javaType, null, attribute, model);
+ this.mapJoin = mapJoin;
+ }
+
+ @Override
+ public MapAttribute<?,K,V> getAttribute() {
+ return (MapAttribute<?,K,V>) super.getAttribute();
+ }
+
+ @Override
+ public PathImpl<?> getParentPath() {
+ return (PathImpl<?>) mapJoin;
+ }
+
+ }
+
+ /**
+ * Defines an {@link Attribute} modelling of a map-key.
+ * <p/>
+ * TODO : Ideally something like this needs to be part of the metamodel package
+ *
+ * @param <K> The type of the map key
+ */
+ public static class MapKeyAttribute<K> implements SingularAttribute<Map<K,?>,K> {
+ private final MapAttribute<?,K,?> attribute;
+ private final CollectionPersister mapPersister;
+ private final Type mapKeyType;
+ private final javax.persistence.metamodel.Type<K> jpaType;
+ private final BindableType jpaBindableType;
+ private final Class<K> jpaBinableJavaType;
+
+ public MapKeyAttribute(QueryBuilderImpl queryBuilder, MapAttribute<?, K, ?> attribute) {
+ this.attribute = attribute;
+ this.jpaType = attribute.getKeyType();
+ this.jpaBinableJavaType = attribute.getKeyJavaType();
+ this.jpaBindableType = PersistenceType.ENTITY.equals( jpaType.getPersistenceType() )
+ ? BindableType.ENTITY_TYPE
+ : BindableType.SINGULAR_ATTRIBUTE;
+
+ String guessedRoleName = determineRole( attribute );
+ SessionFactoryImplementor sfi = (SessionFactoryImplementor)
+ queryBuilder.getEntityManagerFactory().getSessionFactory();
+ mapPersister = sfi.getCollectionPersister( guessedRoleName );
+ if ( mapPersister == null ) {
+ throw new IllegalStateException( "Could not locate collection persister [" + guessedRoleName + "]" );
+ }
+ mapKeyType = mapPersister.getIndexType();
+ if ( mapKeyType == null ) {
+ throw new IllegalStateException( "Could not determine map-key type [" + guessedRoleName + "]" );
+ }
+ }
+
+ private String determineRole(MapAttribute<?,K,?> attribute) {
+ return attribute.getDeclaringType().getJavaType().getName() +
+ '.' + attribute.getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getName() {
+ // TODO : ???
+ return "map-key";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public PersistentAttributeType getPersistentAttributeType() {
+ if ( mapKeyType.isEntityType() ) {
+ return PersistentAttributeType.MANY_TO_ONE;
+ }
+ else if ( mapKeyType.isComponentType() ) {
+ return PersistentAttributeType.EMBEDDED;
+ }
+ else {
+ return PersistentAttributeType.BASIC;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ManagedType<Map<K, ?>> getDeclaringType() {
+ // TODO : ???
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Class<K> getJavaType() {
+ return attribute.getKeyJavaType();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Member getJavaMember() {
+ // TODO : ???
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isAssociation() {
+ return mapKeyType.isEntityType();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCollection() {
+ return false;
+ }
+
+ public boolean isId() {
+ return false;
+ }
+
+ public boolean isVersion() {
+ return false;
+ }
+
+ public boolean isOptional() {
+ return false;
+ }
+
+ public javax.persistence.metamodel.Type<K> getType() {
+ return jpaType;
+ }
+
+ public BindableType getBindableType() {
+ return jpaBindableType;
+ }
+
+ public Class<K> getBindableJavaType() {
+ return jpaBinableJavaType;
+ }
+ }
+
+ /**
+ * Disallow instantiation
+ */
+ private MapKeyHelpers() {
+ }
+
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/PathImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -26,29 +26,41 @@
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Path;
+import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.Bindable;
-import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SingularAttribute;
-import org.hibernate.ejb.criteria.expression.AbstractExpression;
+import org.hibernate.ejb.criteria.expression.ExpressionImpl;
/**
- * A {@link Path} models an individual portion of a join expression.
+ * A {@link Path} models an individual portion of a path expression.
*
* @author Steve Ebersole
*/
-public class PathImpl<X> extends AbstractExpression<X> implements Path<X> {
+public class PathImpl<X> extends ExpressionImpl<X> implements Path<X> {
private final PathImpl<?> origin;
- private Bindable<X> model;
+ private final Attribute<?,?> attribute;
+ private Object model;
+ /**
+ * Constructs a path.
+ *
+ * @param queryBuilder The delegate for building query components.
+ * @param javaType The java type of this path,
+ * @param origin The source ("lhs") of this path.
+ * @param attribute The attribute defining this path element.
+ * @param model The corresponding model of this path.
+ */
protected PathImpl(
QueryBuilderImpl queryBuilder,
Class<X> javaType,
PathImpl<?> origin,
- Bindable<X> model) {
+ Attribute<?,?> attribute,
+ Object model) {
super( queryBuilder, javaType );
this.origin = origin;
+ this.attribute = attribute;
this.model = model;
}
@@ -59,6 +71,10 @@
return origin;
}
+ public Attribute<?, ?> getAttribute() {
+ return attribute;
+ }
+
/**
* {@inheritDoc}
*/
@@ -66,7 +82,7 @@
if ( model == null ) {
throw new IllegalStateException( this + " represents a basic path and not a bindable" );
}
- return model;
+ return (Bindable<X>)model;
}
/**
@@ -76,7 +92,8 @@
* an {@link IllegalStateException}
*/
public Expression<Class<? extends X>> type() {
- throw new IllegalStateException( "type() is not applicable to a primitive path node." ); }
+ throw new BasicPathUsageException( "type() is not applicable to primitive paths.", getAttribute() );
+ }
/**
* {@inheritDoc}
@@ -85,9 +102,13 @@
* an {@link IllegalStateException}
*/
public <Y> Path<Y> get(SingularAttribute<? super X, Y> attribute) {
- throw new IllegalStateException( this + " is a primitive path node." );
+ throw illegalDereference();
}
+ private BasicPathUsageException illegalDereference() {
+ return new BasicPathUsageException( "Primitive path cannot be de-referenced", getAttribute() );
+ }
+
/**
* {@inheritDoc}
* <p/>
@@ -95,7 +116,7 @@
* an {@link IllegalStateException}
*/
public <E, C extends Collection<E>> Expression<C> get(PluralAttribute<X, C, E> collection) {
- throw new IllegalStateException( this + " is a primitive path node." );
+ throw illegalDereference();
}
/**
@@ -105,7 +126,7 @@
* an {@link IllegalStateException}
*/
public <K, V, M extends Map<K, V>> Expression<M> get(MapAttribute<X, K, V> map) {
- throw new IllegalStateException( this + " is a primitive path node." );
+ throw illegalDereference();
}
/**
@@ -115,7 +136,7 @@
* an {@link IllegalStateException}
*/
public <Y> Path<Y> get(String attributeName) {
- throw new IllegalStateException( this + " is a primitive path node." );
+ throw illegalDereference();
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryBuilderImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryBuilderImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/QueryBuilderImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -73,7 +73,7 @@
*
* @return The underlying {@link EntityManagerFactoryImpl}
*/
- protected EntityManagerFactoryImpl getEntityManagerFactory() {
+ public EntityManagerFactoryImpl getEntityManagerFactory() {
return entityManagerFactory;
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/RootImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -22,6 +22,7 @@
package org.hibernate.ejb.criteria;
import javax.persistence.criteria.Root;
+import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.EntityType;
/**
@@ -41,4 +42,9 @@
return ( EntityType<X> ) super.getModel();
}
+ @Override
+ protected Attribute<X, ?> getAttribute(String name) {
+ return (Attribute<X, ?>) getModel().getAttribute( name );
+ }
+
}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/SetJoinImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,49 @@
+/*
+ * 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.ejb.criteria;
+
+import javax.persistence.criteria.JoinType;
+import javax.persistence.criteria.SetJoin;
+import javax.persistence.metamodel.SetAttribute;
+
+/**
+ * Represents a join to a persistent collection, defined as type {@link java.util.Set}, whose elements
+ * are associations.
+ *
+ * @author Steve Ebersole
+ */
+public class SetJoinImpl<O,E> extends JoinImpl<O,E> implements SetJoin<O,E> {
+ public SetJoinImpl(
+ QueryBuilderImpl queryBuilder,
+ Class<E> javaType,
+ PathImpl<O> lhs,
+ SetAttribute<? super O, ?> joinProperty,
+ JoinType joinType) {
+ super(queryBuilder, javaType, lhs, joinProperty, joinType);
+ }
+
+ @Override
+ public SetAttribute<? super O, E> getModel() {
+ return (SetAttribute<? super O, E>) super.getAttribute();
+ }
+
+}
Deleted: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractExpression.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractExpression.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -1,89 +0,0 @@
-/*
- * 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.ejb.criteria.expression;
-
-import java.util.Collection;
-import javax.persistence.criteria.Expression;
-import javax.persistence.criteria.Predicate;
-
-import org.hibernate.ejb.criteria.QueryBuilderImpl;
-
-/**
- * TODO : javadoc
- *
- * @author Steve Ebersole
- */
-public class AbstractExpression<T> extends SelectionImpl<T> implements Expression<T> {
- protected AbstractExpression(QueryBuilderImpl queryBuilder, Class<T> javaType) {
- super( queryBuilder, javaType );
- }
-
- /**
- * {@inheritDoc}
- */
- public <X> Expression<X> as(Class<X> type) {
- // TODO-STEVE : implement - needs a cast expression
- throw new UnsupportedOperationException( "Not yet implemented!" );
- }
-
- /**
- * {@inheritDoc}
- */
- public Predicate isNull() {
- return queryBuilder().isNull( this );
- }
-
- /**
- * {@inheritDoc}
- */
- public Predicate isNotNull() {
- return queryBuilder().isNotNull( this );
- }
-
- /**
- * {@inheritDoc}
- */
- public Predicate in(Object... values) {
- return queryBuilder().in( this, values );
- }
-
- /**
- * {@inheritDoc}
- */
- public Predicate in(Expression<?>... values) {
- return queryBuilder().in( this, values );
- }
-
- /**
- * {@inheritDoc}
- */
- public Predicate in(Collection<?> values) {
- return queryBuilder().in( this, values );
- }
-
- /**
- * {@inheritDoc}
- */
- public Predicate in(Expression<Collection<?>> values) {
- return queryBuilder().in( this, values );
- }
-}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/CollectionExpression.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,74 @@
+/*
+ * 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.ejb.criteria.expression;
+
+import javax.persistence.metamodel.PluralAttribute;
+import org.hibernate.ejb.criteria.QueryBuilderImpl;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionExpression<C> extends ExpressionImpl<C> {
+ private final CollectionPersister persister;
+ private final PluralAttribute<?, C, ?> attribute;
+
+ public CollectionExpression(
+ QueryBuilderImpl queryBuilder,
+ Class<C> javaType,
+ PluralAttribute<?, C, ?> attribute) {
+ this( queryBuilder, javaType, resolvePersister( queryBuilder, attribute ), attribute );
+ }
+
+ private static CollectionPersister resolvePersister(QueryBuilderImpl queryBuilder, PluralAttribute attribute) {
+ SessionFactoryImplementor sfi = (SessionFactoryImplementor)
+ queryBuilder.getEntityManagerFactory().getSessionFactory();
+ return sfi.getCollectionPersister( resolveRole( attribute ) );
+ }
+
+ private static String resolveRole(PluralAttribute attribute) {
+ return attribute.getDeclaringType().getJavaType().getName() +
+ '.' + attribute.getName();
+ }
+
+ public CollectionExpression(
+ QueryBuilderImpl queryBuilder,
+ Class<C> javaType,
+ CollectionPersister persister,
+ PluralAttribute<?, C, ?> attribute) {
+ super(queryBuilder, javaType);
+ this.persister = persister;
+ this.attribute = attribute;
+ }
+
+ public PluralAttribute<?, C, ?> getAttribute() {
+ return attribute;
+ }
+
+ public CollectionPersister getPersister() {
+ return persister;
+ }
+
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/EntityTypeExpression.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -28,7 +28,7 @@
*
* @author Steve Ebersole
*/
-public class EntityTypeExpression<T> extends AbstractExpression<T> {
+public class EntityTypeExpression<T> extends ExpressionImpl<T> {
public EntityTypeExpression(QueryBuilderImpl queryBuilder, Class<T> javaType) {
super( queryBuilder, javaType );
}
Copied: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java (from rev 17222, core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/AbstractExpression.java)
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ExpressionImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,89 @@
+/*
+ * 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.ejb.criteria.expression;
+
+import java.util.Collection;
+import javax.persistence.criteria.Expression;
+import javax.persistence.criteria.Predicate;
+
+import org.hibernate.ejb.criteria.QueryBuilderImpl;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class ExpressionImpl<T> extends SelectionImpl<T> implements Expression<T> {
+ public ExpressionImpl(QueryBuilderImpl queryBuilder, Class<T> javaType) {
+ super( queryBuilder, javaType );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public <X> Expression<X> as(Class<X> type) {
+ // TODO-STEVE : implement - needs a cast expression
+ throw new UnsupportedOperationException( "Not yet implemented!" );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Predicate isNull() {
+ return queryBuilder().isNull( this );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Predicate isNotNull() {
+ return queryBuilder().isNotNull( this );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Predicate in(Object... values) {
+ return queryBuilder().in( this, values );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Predicate in(Expression<?>... values) {
+ return queryBuilder().in( this, values );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Predicate in(Collection<?> values) {
+ return queryBuilder().in( this, values );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Predicate in(Expression<Collection<?>> values) {
+ return queryBuilder().in( this, values );
+ }
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/FunctionExpressionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/FunctionExpressionImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/FunctionExpressionImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -32,7 +32,7 @@
*
* @author Steve Ebersole
*/
-public class FunctionExpressionImpl<X> extends AbstractExpression<X> implements Expression<X> {
+public class FunctionExpressionImpl<X> extends ExpressionImpl<X> implements Expression<X> {
private final String functionName;
private final List<Expression<?>> argumentExpressions;
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ListIndexExpression.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,23 @@
+package org.hibernate.ejb.criteria.expression;
+
+import javax.persistence.metamodel.ListAttribute;
+import org.hibernate.ejb.criteria.QueryBuilderImpl;
+
+/**
+ * An expression for referring to the index of a list.
+ *
+ * @author Steve Ebersole
+ */
+public class ListIndexExpression extends ExpressionImpl<Integer> {
+ private final ListAttribute<?,?> listAttribute;
+
+ public ListIndexExpression(QueryBuilderImpl queryBuilder, ListAttribute<?,?> listAttribute) {
+ super( queryBuilder, Integer.class );
+ this.listAttribute = listAttribute;
+ }
+
+ public ListAttribute<?,?> getListAttribute() {
+ return listAttribute;
+ }
+
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/LiteralExpression.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -28,7 +28,7 @@
*
* @author Steve Ebersole
*/
-public class LiteralExpression<T> extends AbstractExpression<T> {
+public class LiteralExpression<T> extends ExpressionImpl<T> {
private final T literal;
public LiteralExpression(
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/ParameterExpressionImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -31,7 +31,7 @@
*
* @author Steve Ebersole
*/
-public class ParameterExpressionImpl<T> extends AbstractExpression<T> implements ParameterExpression<T> {
+public class ParameterExpressionImpl<T> extends ExpressionImpl<T> implements ParameterExpression<T> {
private final String name;
private final Integer position;
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AverageAggregrateFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AverageAggregrateFunction.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/AverageAggregrateFunction.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,43 @@
+/*
+ * 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.ejb.criteria.expression.function;
+
+import javax.persistence.criteria.Expression;
+
+import org.hibernate.ejb.criteria.expression.FunctionExpressionImpl;
+import org.hibernate.ejb.criteria.QueryBuilderImpl;
+
+/**
+ * Implementation of a <tt>AVG</tt> function providing convenience in construction.
+ * <p/>
+ * Parameterized as {@link Double} because thats what JPA states that the return
+ * from <tt>AVG</tt> should be.
+ *
+ * @author Steve Ebersole
+ */
+public class AverageAggregrateFunction extends FunctionExpressionImpl<Double> {
+ public AverageAggregrateFunction(
+ QueryBuilderImpl queryBuilder,
+ Expression<? extends Number> expression) {
+ super( queryBuilder, Double.class, "avg", expression );
+ }
+}
Added: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SumAggregateFunction.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SumAggregateFunction.java (rev 0)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/expression/function/SumAggregateFunction.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -0,0 +1,43 @@
+/*
+ * 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.ejb.criteria.expression.function;
+
+import javax.persistence.criteria.Expression;
+
+import org.hibernate.ejb.criteria.expression.FunctionExpressionImpl;
+import org.hibernate.ejb.criteria.QueryBuilderImpl;
+
+/**
+ * Implementation of a <tt>SUM</tt> function providing convenience in construction.
+ * <p/>
+ * Parameterized as {@link Number N extends Number} because thats what JPA states
+ * that the return from <tt>SUM</tt> should be.
+ *
+ * @author Steve Ebersole
+ */
+public class SumAggregateFunction<N extends Number> extends FunctionExpressionImpl<N> {
+ public SumAggregateFunction(
+ QueryBuilderImpl queryBuilder,
+ Expression<N> expression) {
+ super( queryBuilder, expression.getJavaType(), "sum", expression );
+ }
+}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java 2009-08-04 17:07:20 UTC (rev 17226)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/criteria/predicate/AbstractPredicateImpl.java 2009-08-04 18:01:45 UTC (rev 17227)
@@ -25,7 +25,7 @@
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Selection;
-import org.hibernate.ejb.criteria.expression.AbstractExpression;
+import org.hibernate.ejb.criteria.expression.ExpressionImpl;
import org.hibernate.ejb.criteria.QueryBuilderImpl;
/**
@@ -34,7 +34,7 @@
*
* @author Steve Ebersole
*/
-public abstract class AbstractPredicateImpl extends AbstractExpression<Boolean> implements Predicate {
+public abstract class AbstractPredicateImpl extends ExpressionImpl<Boolean> implements Predicate {
private boolean negated;
protected AbstractPredicateImpl(QueryBuilderImpl queryBuilder) {
14 years, 8 months
Hibernate SVN: r17226 - jpa-api/trunk/src/main/java/javax/persistence/criteria.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-08-04 13:07:20 -0400 (Tue, 04 Aug 2009)
New Revision: 17226
Modified:
jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java
Log:
fixed method signatures of attribute-name (string-based) joins
Modified: jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java
===================================================================
--- jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java 2009-08-03 03:14:57 UTC (rev 17225)
+++ jpa-api/trunk/src/main/java/javax/persistence/criteria/From.java 2009-08-04 17:07:20 UTC (rev 17226)
@@ -122,7 +122,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> Join<X, Y> join(String attributeName);
+ <Y> Join<X, Y> join(String attributeName);
/**
* Join to the specified Collection-valued attribute using an
@@ -133,7 +133,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName);
+ <Y> CollectionJoin<X, Y> joinCollection(String attributeName);
/**
* Join to the specified Set-valued attribute using an inner
@@ -144,7 +144,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> SetJoin<X, Y> joinSet(String attributeName);
+ <Y> SetJoin<X, Y> joinSet(String attributeName);
/**
* Join to the specified List-valued attribute using an inner
@@ -155,7 +155,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> ListJoin<X, Y> joinList(String attributeName);
+ <Y> ListJoin<X, Y> joinList(String attributeName);
/**
* Join to the specified Map-valued attribute using an inner
@@ -166,7 +166,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, K, V> MapJoin<X, K, V> joinMap(String attributeName);
+ <K, V> MapJoin<X, K, V> joinMap(String attributeName);
/**
@@ -179,7 +179,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> Join<X, Y> join(String attributeName, JoinType jt);
+ <Y> Join<X, Y> join(String attributeName, JoinType jt);
/**
* Join to the specified Collection-valued attribute using
@@ -191,7 +191,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt);
+ <Y> CollectionJoin<X, Y> joinCollection(String attributeName, JoinType jt);
/**
* Join to the specified Set-valued attribute using
@@ -203,7 +203,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt);
+ <Y> SetJoin<X, Y> joinSet(String attributeName, JoinType jt);
/**
* Join to the specified List-valued attribute using
@@ -215,7 +215,7 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt);
+ <Y> ListJoin<X, Y> joinList(String attributeName, JoinType jt);
/**
* Join to the specified Map-valued attribute using
@@ -227,5 +227,5 @@
* @throws IllegalArgumentException if attribute of the given
* name does not exist
*/
- <X, K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt);
+ <K, V> MapJoin<X, K, V> joinMap(String attributeName, JoinType jt);
}
14 years, 8 months
Hibernate SVN: r17225 - core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-08-02 23:14:57 -0400 (Sun, 02 Aug 2009)
New Revision: 17225
Removed:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt
Log:
Oops, delete these three files, these files should not be commited
Deleted: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java 2009-08-03 02:58:24 UTC (rev 17224)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java 2009-08-03 03:14:57 UTC (rev 17225)
@@ -1,3887 +0,0 @@
-// $ANTLR 2.7.2: "sql-gen.g" -> "SqlGeneratorBase.java"$
-
-// $Id: sql-gen.g 15746 2009-01-06 17:14:14Z cbredesen $
-package org.hibernate.hql.antlr;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-import antlr.TreeParser;
-import antlr.Token;
-import antlr.collections.AST;
-import antlr.RecognitionException;
-import antlr.ANTLRException;
-import antlr.NoViableAltException;
-import antlr.MismatchedTokenException;
-import antlr.SemanticException;
-import antlr.collections.impl.BitSet;
-import antlr.ASTPair;
-import antlr.collections.impl.ASTArray;
-
-
-/**
- * SQL Generator Tree Parser, providing SQL rendering of SQL ASTs produced by the previous phase, HqlSqlWalker. All
- * syntax decoration such as extra spaces, lack of spaces, extra parens, etc. should be added by this class.
- * <br>
- * This grammar processes the HQL/SQL AST and produces an SQL string. The intent is to move dialect-specific
- * code into a sub-class that will override some of the methods, just like the other two grammars in this system.
- * @author Joshua Davis (joshua(a)hibernate.org)
- */
-public class SqlGeneratorBase extends antlr.TreeParser implements SqlTokenTypes
- {
-
- private static Log log = LogFactory.getLog(SqlGeneratorBase.class);
-
- /** the buffer resulting SQL statement is written to */
- private StringBuffer buf = new StringBuffer();
-
- protected void out(String s) {
- buf.append(s);
- }
-
- /**
- * Returns the last character written to the output, or -1 if there isn't one.
- */
- protected int getLastChar() {
- int len = buf.length();
- if ( len == 0 )
- return -1;
- else
- return buf.charAt( len - 1 );
- }
-
- /**
- * Add a aspace if the previous token was not a space or a parenthesis.
- */
- protected void optionalSpace() {
- // Implemented in the sub-class.
- }
-
- protected void out(AST n) {
- out(n.getText());
- }
-
- protected void separator(AST n, String sep) {
- if (n.getNextSibling() != null)
- out(sep);
- }
-
- protected boolean hasText(AST a) {
- String t = a.getText();
- return t != null && t.length() > 0;
- }
-
- protected void fromFragmentSeparator(AST a) {
- // moved this impl into the subclass...
- }
-
- protected void nestedFromFragment(AST d,AST parent) {
- // moved this impl into the subclass...
- }
-
- protected StringBuffer getStringBuffer() {
- return buf;
- }
-
- protected void nyi(AST n) {
- throw new UnsupportedOperationException("Unsupported node: " + n);
- }
-
- protected void beginFunctionTemplate(AST m,AST i) {
- // if template is null we just write the function out as it appears in the hql statement
- out(i);
- out("(");
- }
-
- protected void endFunctionTemplate(AST m) {
- out(")");
- }
-
- protected void commaBetweenParameters(String comma) {
- out(comma);
- }
-public SqlGeneratorBase() {
- tokenNames = _tokenNames;
-}
-
- public final void statement(AST _t) throws RecognitionException {
-
- AST statement_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case SELECT:
- {
- selectStatement(_t);
- _t = _retTree;
- break;
- }
- case UPDATE:
- {
- updateStatement(_t);
- _t = _retTree;
- break;
- }
- case DELETE:
- {
- deleteStatement(_t);
- _t = _retTree;
- break;
- }
- case INSERT:
- {
- insertStatement(_t);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void selectStatement(AST _t) throws RecognitionException {
-
- AST selectStatement_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t3 = _t;
- AST tmp1_AST_in = (AST)_t;
- match(_t,SELECT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("select ");
- }
- selectClause(_t);
- _t = _retTree;
- from(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case WHERE:
- {
- AST __t5 = _t;
- AST tmp2_AST_in = (AST)_t;
- match(_t,WHERE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" where ");
- }
- whereExpr(_t);
- _t = _retTree;
- _t = __t5;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- case GROUP:
- case ORDER:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case GROUP:
- {
- AST __t7 = _t;
- AST tmp3_AST_in = (AST)_t;
- match(_t,GROUP);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" group by ");
- }
- groupExprs(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case HAVING:
- {
- AST __t9 = _t;
- AST tmp4_AST_in = (AST)_t;
- match(_t,HAVING);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" having ");
- }
- booleanExpr(_t,false);
- _t = _retTree;
- _t = __t9;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- _t = __t7;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- case ORDER:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ORDER:
- {
- AST __t11 = _t;
- AST tmp5_AST_in = (AST)_t;
- match(_t,ORDER);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" order by ");
- }
- orderExprs(_t);
- _t = _retTree;
- _t = __t11;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- _t = __t3;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void updateStatement(AST _t) throws RecognitionException {
-
- AST updateStatement_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t13 = _t;
- AST tmp6_AST_in = (AST)_t;
- match(_t,UPDATE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("update ");
- }
- AST __t14 = _t;
- AST tmp7_AST_in = (AST)_t;
- match(_t,FROM);
- _t = _t.getFirstChild();
- fromTable(_t);
- _t = _retTree;
- _t = __t14;
- _t = _t.getNextSibling();
- setClause(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case WHERE:
- {
- whereClause(_t);
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- _t = __t13;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void deleteStatement(AST _t) throws RecognitionException {
-
- AST deleteStatement_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t17 = _t;
- AST tmp8_AST_in = (AST)_t;
- match(_t,DELETE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("delete");
- }
- from(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case WHERE:
- {
- whereClause(_t);
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- _t = __t17;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void insertStatement(AST _t) throws RecognitionException {
-
- AST insertStatement_AST_in = (AST)_t;
- AST i = null;
-
- try { // for error handling
- AST __t20 = _t;
- AST tmp9_AST_in = (AST)_t;
- match(_t,INSERT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out( "insert " );
- }
- i = (AST)_t;
- match(_t,INTO);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out( i ); out( " " );
- }
- selectStatement(_t);
- _t = _retTree;
- _t = __t20;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void selectClause(AST _t) throws RecognitionException {
-
- AST selectClause_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t48 = _t;
- AST tmp10_AST_in = (AST)_t;
- match(_t,SELECT_CLAUSE);
- _t = _t.getFirstChild();
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ALL:
- case DISTINCT:
- {
- distinctOrAll(_t);
- _t = _retTree;
- break;
- }
- case COUNT:
- case DOT:
- case FALSE:
- case SELECT:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CONSTRUCTOR:
- case CASE2:
- case METHOD_CALL:
- case UNARY_MINUS:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case SELECT_EXPR:
- case SQL_NODE:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- {
- int _cnt51=0;
- _loop51:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_tokenSet_0.member(_t.getType()))) {
- selectColumn(_t);
- _t = _retTree;
- }
- else {
- if ( _cnt51>=1 ) { break _loop51; } else {throw new NoViableAltException(_t);}
- }
-
- _cnt51++;
- } while (true);
- }
- _t = __t48;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void from(AST _t) throws RecognitionException {
-
- AST from_AST_in = (AST)_t;
- AST f = null;
-
- try { // for error handling
- AST __t66 = _t;
- f = _t==ASTNULL ? null :(AST)_t;
- match(_t,FROM);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" from ");
- }
- {
- _loop68:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
- fromTable(_t);
- _t = _retTree;
- }
- else {
- break _loop68;
- }
-
- } while (true);
- }
- _t = __t66;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void whereExpr(AST _t) throws RecognitionException {
-
- AST whereExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case FILTERS:
- {
- filters(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case THETA_JOINS:
- {
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- thetaJoins(_t);
- _t = _retTree;
- break;
- }
- case 3:
- case AND:
- case BETWEEN:
- case EXISTS:
- case IN:
- case LIKE:
- case NOT:
- case OR:
- case IS_NOT_NULL:
- case IS_NULL:
- case NOT_BETWEEN:
- case NOT_IN:
- case NOT_LIKE:
- case EQ:
- case NE:
- case LT:
- case GT:
- case LE:
- case GE:
- case SQL_TOKEN:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case AND:
- case BETWEEN:
- case EXISTS:
- case IN:
- case LIKE:
- case NOT:
- case OR:
- case IS_NOT_NULL:
- case IS_NULL:
- case NOT_BETWEEN:
- case NOT_IN:
- case NOT_LIKE:
- case EQ:
- case NE:
- case LT:
- case GT:
- case LE:
- case GE:
- case SQL_TOKEN:
- {
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- booleanExpr(_t, true );
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- break;
- }
- case THETA_JOINS:
- {
- thetaJoins(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case AND:
- case BETWEEN:
- case EXISTS:
- case IN:
- case LIKE:
- case NOT:
- case OR:
- case IS_NOT_NULL:
- case IS_NULL:
- case NOT_BETWEEN:
- case NOT_IN:
- case NOT_LIKE:
- case EQ:
- case NE:
- case LT:
- case GT:
- case LE:
- case GE:
- case SQL_TOKEN:
- {
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- booleanExpr(_t, true );
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- break;
- }
- case AND:
- case BETWEEN:
- case EXISTS:
- case IN:
- case LIKE:
- case NOT:
- case OR:
- case IS_NOT_NULL:
- case IS_NULL:
- case NOT_BETWEEN:
- case NOT_IN:
- case NOT_LIKE:
- case EQ:
- case NE:
- case LT:
- case GT:
- case LE:
- case GE:
- case SQL_TOKEN:
- {
- booleanExpr(_t,false);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void groupExprs(AST _t) throws RecognitionException {
-
- AST groupExprs_AST_in = (AST)_t;
-
- try { // for error handling
- expr(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ALL:
- case ANY:
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case SELECT:
- case SOME:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case VECTOR_EXPR:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- if ( inputState.guessing==0 ) {
- out(" , ");
- }
- groupExprs(_t);
- _t = _retTree;
- break;
- }
- case 3:
- case HAVING:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void booleanExpr(AST _t,
- boolean parens
- ) throws RecognitionException {
-
- AST booleanExpr_AST_in = (AST)_t;
- AST st = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case AND:
- case NOT:
- case OR:
- {
- booleanOp(_t, parens );
- _t = _retTree;
- break;
- }
- case BETWEEN:
- case EXISTS:
- case IN:
- case LIKE:
- case IS_NOT_NULL:
- case IS_NULL:
- case NOT_BETWEEN:
- case NOT_IN:
- case NOT_LIKE:
- case EQ:
- case NE:
- case LT:
- case GT:
- case LE:
- case GE:
- {
- comparisonExpr(_t, parens );
- _t = _retTree;
- break;
- }
- case SQL_TOKEN:
- {
- st = (AST)_t;
- match(_t,SQL_TOKEN);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(st);
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void orderExprs(AST _t) throws RecognitionException {
-
- AST orderExprs_AST_in = (AST)_t;
- AST dir = null;
-
- try { // for error handling
- {
- expr(_t);
- _t = _retTree;
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ASCENDING:
- case DESCENDING:
- {
- dir = _t==ASTNULL ? null : (AST)_t;
- orderDirection(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" "); out(dir);
- }
- break;
- }
- case 3:
- case ALL:
- case ANY:
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case SELECT:
- case SOME:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case VECTOR_EXPR:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ALL:
- case ANY:
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case SELECT:
- case SOME:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case VECTOR_EXPR:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- if ( inputState.guessing==0 ) {
- out(", ");
- }
- orderExprs(_t);
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void fromTable(AST _t) throws RecognitionException {
-
- AST fromTable_AST_in = (AST)_t;
- AST a = null;
- AST b = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case FROM_FRAGMENT:
- {
- AST __t70 = _t;
- a = _t==ASTNULL ? null :(AST)_t;
- match(_t,FROM_FRAGMENT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(a);
- }
- {
- _loop72:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
- tableJoin(_t, a );
- _t = _retTree;
- }
- else {
- break _loop72;
- }
-
- } while (true);
- }
- if ( inputState.guessing==0 ) {
- fromFragmentSeparator(a);
- }
- _t = __t70;
- _t = _t.getNextSibling();
- break;
- }
- case JOIN_FRAGMENT:
- {
- AST __t73 = _t;
- b = _t==ASTNULL ? null :(AST)_t;
- match(_t,JOIN_FRAGMENT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(b);
- }
- {
- _loop75:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
- tableJoin(_t, b );
- _t = _retTree;
- }
- else {
- break _loop75;
- }
-
- } while (true);
- }
- if ( inputState.guessing==0 ) {
- fromFragmentSeparator(b);
- }
- _t = __t73;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void setClause(AST _t) throws RecognitionException {
-
- AST setClause_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t22 = _t;
- AST tmp11_AST_in = (AST)_t;
- match(_t,SET);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" set ");
- }
- comparisonExpr(_t,false);
- _t = _retTree;
- {
- _loop24:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_tokenSet_1.member(_t.getType()))) {
- if ( inputState.guessing==0 ) {
- out(", ");
- }
- comparisonExpr(_t,false);
- _t = _retTree;
- }
- else {
- break _loop24;
- }
-
- } while (true);
- }
- _t = __t22;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void whereClause(AST _t) throws RecognitionException {
-
- AST whereClause_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t26 = _t;
- AST tmp12_AST_in = (AST)_t;
- match(_t,WHERE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" where ");
- }
- whereClauseExpr(_t);
- _t = _retTree;
- _t = __t26;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void comparisonExpr(AST _t,
- boolean parens
- ) throws RecognitionException {
-
- AST comparisonExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case EQ:
- case NE:
- case LT:
- case GT:
- case LE:
- case GE:
- {
- binaryComparisonExpression(_t);
- _t = _retTree;
- break;
- }
- case BETWEEN:
- case EXISTS:
- case IN:
- case LIKE:
- case IS_NOT_NULL:
- case IS_NULL:
- case NOT_BETWEEN:
- case NOT_IN:
- case NOT_LIKE:
- {
- if ( inputState.guessing==0 ) {
- if (parens) out("(");
- }
- exoticComparisonExpression(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- if (parens) out(")");
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void whereClauseExpr(AST _t) throws RecognitionException {
-
- AST whereClauseExpr_AST_in = (AST)_t;
-
- try { // for error handling
- boolean synPredMatched29 = false;
- if (((_t.getType()==SQL_TOKEN))) {
- AST __t29 = _t;
- synPredMatched29 = true;
- inputState.guessing++;
- try {
- {
- AST tmp13_AST_in = (AST)_t;
- match(_t,SQL_TOKEN);
- _t = _t.getNextSibling();
- }
- }
- catch (RecognitionException pe) {
- synPredMatched29 = false;
- }
- _t = __t29;
- inputState.guessing--;
- }
- if ( synPredMatched29 ) {
- conditionList(_t);
- _t = _retTree;
- }
- else if ((_tokenSet_2.member(_t.getType()))) {
- booleanExpr(_t, false );
- _t = _retTree;
- }
- else {
- throw new NoViableAltException(_t);
- }
-
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void conditionList(AST _t) throws RecognitionException {
-
- AST conditionList_AST_in = (AST)_t;
-
- try { // for error handling
- sqlToken(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case SQL_TOKEN:
- {
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- conditionList(_t);
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void expr(AST _t) throws RecognitionException {
-
- AST expr_AST_in = (AST)_t;
- AST e = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- simpleExpr(_t);
- _t = _retTree;
- break;
- }
- case VECTOR_EXPR:
- {
- AST __t116 = _t;
- AST tmp14_AST_in = (AST)_t;
- match(_t,VECTOR_EXPR);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("(");
- }
- {
- _loop118:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_tokenSet_3.member(_t.getType()))) {
- e = _t==ASTNULL ? null : (AST)_t;
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- separator(e," , ");
- }
- }
- else {
- break _loop118;
- }
-
- } while (true);
- }
- if ( inputState.guessing==0 ) {
- out(")");
- }
- _t = __t116;
- _t = _t.getNextSibling();
- break;
- }
- case SELECT:
- {
- parenSelect(_t);
- _t = _retTree;
- break;
- }
- case ANY:
- {
- AST __t119 = _t;
- AST tmp15_AST_in = (AST)_t;
- match(_t,ANY);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("any ");
- }
- quantified(_t);
- _t = _retTree;
- _t = __t119;
- _t = _t.getNextSibling();
- break;
- }
- case ALL:
- {
- AST __t120 = _t;
- AST tmp16_AST_in = (AST)_t;
- match(_t,ALL);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("all ");
- }
- quantified(_t);
- _t = _retTree;
- _t = __t120;
- _t = _t.getNextSibling();
- break;
- }
- case SOME:
- {
- AST __t121 = _t;
- AST tmp17_AST_in = (AST)_t;
- match(_t,SOME);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("some ");
- }
- quantified(_t);
- _t = _retTree;
- _t = __t121;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void orderDirection(AST _t) throws RecognitionException {
-
- AST orderDirection_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ASCENDING:
- {
- AST tmp18_AST_in = (AST)_t;
- match(_t,ASCENDING);
- _t = _t.getNextSibling();
- break;
- }
- case DESCENDING:
- {
- AST tmp19_AST_in = (AST)_t;
- match(_t,DESCENDING);
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void filters(AST _t) throws RecognitionException {
-
- AST filters_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t42 = _t;
- AST tmp20_AST_in = (AST)_t;
- match(_t,FILTERS);
- _t = _t.getFirstChild();
- conditionList(_t);
- _t = _retTree;
- _t = __t42;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void thetaJoins(AST _t) throws RecognitionException {
-
- AST thetaJoins_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t44 = _t;
- AST tmp21_AST_in = (AST)_t;
- match(_t,THETA_JOINS);
- _t = _t.getFirstChild();
- conditionList(_t);
- _t = _retTree;
- _t = __t44;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void sqlToken(AST _t) throws RecognitionException {
-
- AST sqlToken_AST_in = (AST)_t;
- AST t = null;
-
- try { // for error handling
- t = (AST)_t;
- match(_t,SQL_TOKEN);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(t);
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void distinctOrAll(AST _t) throws RecognitionException {
-
- AST distinctOrAll_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case DISTINCT:
- {
- AST tmp22_AST_in = (AST)_t;
- match(_t,DISTINCT);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out("distinct ");
- }
- break;
- }
- case ALL:
- {
- AST tmp23_AST_in = (AST)_t;
- match(_t,ALL);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out("all ");
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void selectColumn(AST _t) throws RecognitionException {
-
- AST selectColumn_AST_in = (AST)_t;
- AST p = null;
- AST sc = null;
-
- try { // for error handling
- p = _t==ASTNULL ? null : (AST)_t;
- selectExpr(_t);
- _t = _retTree;
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case SELECT_COLUMNS:
- {
- sc = (AST)_t;
- match(_t,SELECT_COLUMNS);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(sc);
- }
- break;
- }
- case 3:
- case COUNT:
- case DOT:
- case FALSE:
- case SELECT:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CONSTRUCTOR:
- case CASE2:
- case METHOD_CALL:
- case UNARY_MINUS:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case SELECT_EXPR:
- case SQL_NODE:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- if ( inputState.guessing==0 ) {
- separator( (sc != null) ? sc : p,", ");
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void selectExpr(AST _t) throws RecognitionException {
-
- AST selectExpr_AST_in = (AST)_t;
- AST e = null;
- AST c = null;
- AST param = null;
- AST sn = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case DOT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case SELECT_EXPR:
- {
- e = _t==ASTNULL ? null : (AST)_t;
- selectAtom(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(e);
- }
- break;
- }
- case COUNT:
- {
- count(_t);
- _t = _retTree;
- break;
- }
- case CONSTRUCTOR:
- {
- AST __t55 = _t;
- AST tmp24_AST_in = (AST)_t;
- match(_t,CONSTRUCTOR);
- _t = _t.getFirstChild();
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case DOT:
- {
- AST tmp25_AST_in = (AST)_t;
- match(_t,DOT);
- _t = _t.getNextSibling();
- break;
- }
- case IDENT:
- {
- AST tmp26_AST_in = (AST)_t;
- match(_t,IDENT);
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- {
- int _cnt58=0;
- _loop58:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_tokenSet_0.member(_t.getType()))) {
- selectColumn(_t);
- _t = _retTree;
- }
- else {
- if ( _cnt58>=1 ) { break _loop58; } else {throw new NoViableAltException(_t);}
- }
-
- _cnt58++;
- } while (true);
- }
- _t = __t55;
- _t = _t.getNextSibling();
- break;
- }
- case METHOD_CALL:
- {
- methodCall(_t);
- _t = _retTree;
- break;
- }
- case AGGREGATE:
- {
- aggregate(_t);
- _t = _retTree;
- break;
- }
- case FALSE:
- case TRUE:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- {
- c = _t==ASTNULL ? null : (AST)_t;
- constant(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(c);
- }
- break;
- }
- case CASE:
- case CASE2:
- case UNARY_MINUS:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- {
- arithmeticExpr(_t);
- _t = _retTree;
- break;
- }
- case PARAM:
- {
- param = (AST)_t;
- match(_t,PARAM);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(param);
- }
- break;
- }
- case SQL_NODE:
- {
- sn = (AST)_t;
- match(_t,SQL_NODE);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(sn);
- }
- break;
- }
- case SELECT:
- {
- if ( inputState.guessing==0 ) {
- out("(");
- }
- selectStatement(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void selectAtom(AST _t) throws RecognitionException {
-
- AST selectAtom_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case DOT:
- {
- AST tmp27_AST_in = (AST)_t;
- match(_t,DOT);
- _t = _t.getNextSibling();
- break;
- }
- case SQL_TOKEN:
- {
- AST tmp28_AST_in = (AST)_t;
- match(_t,SQL_TOKEN);
- _t = _t.getNextSibling();
- break;
- }
- case ALIAS_REF:
- {
- AST tmp29_AST_in = (AST)_t;
- match(_t,ALIAS_REF);
- _t = _t.getNextSibling();
- break;
- }
- case SELECT_EXPR:
- {
- AST tmp30_AST_in = (AST)_t;
- match(_t,SELECT_EXPR);
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void count(AST _t) throws RecognitionException {
-
- AST count_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t60 = _t;
- AST tmp31_AST_in = (AST)_t;
- match(_t,COUNT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("count(");
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ALL:
- case DISTINCT:
- {
- distinctOrAll(_t);
- _t = _retTree;
- break;
- }
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case ROW_STAR:
- case UNARY_MINUS:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- countExpr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- _t = __t60;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void methodCall(AST _t) throws RecognitionException {
-
- AST methodCall_AST_in = (AST)_t;
- AST m = null;
- AST i = null;
-
- try { // for error handling
- AST __t157 = _t;
- m = _t==ASTNULL ? null :(AST)_t;
- match(_t,METHOD_CALL);
- _t = _t.getFirstChild();
- i = (AST)_t;
- match(_t,METHOD_NAME);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- beginFunctionTemplate(m,i);
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case EXPR_LIST:
- {
- AST __t159 = _t;
- AST tmp32_AST_in = (AST)_t;
- match(_t,EXPR_LIST);
- _t = _t.getFirstChild();
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ALL:
- case ANY:
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case SELECT:
- case SOME:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case VECTOR_EXPR:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- arguments(_t);
- _t = _retTree;
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- _t = __t159;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- if ( inputState.guessing==0 ) {
- endFunctionTemplate(m);
- }
- _t = __t157;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void aggregate(AST _t) throws RecognitionException {
-
- AST aggregate_AST_in = (AST)_t;
- AST a = null;
-
- try { // for error handling
- AST __t155 = _t;
- a = _t==ASTNULL ? null :(AST)_t;
- match(_t,AGGREGATE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(a); out("(");
- }
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- _t = __t155;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void constant(AST _t) throws RecognitionException {
-
- AST constant_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case NUM_DOUBLE:
- {
- AST tmp33_AST_in = (AST)_t;
- match(_t,NUM_DOUBLE);
- _t = _t.getNextSibling();
- break;
- }
- case NUM_FLOAT:
- {
- AST tmp34_AST_in = (AST)_t;
- match(_t,NUM_FLOAT);
- _t = _t.getNextSibling();
- break;
- }
- case NUM_INT:
- {
- AST tmp35_AST_in = (AST)_t;
- match(_t,NUM_INT);
- _t = _t.getNextSibling();
- break;
- }
- case NUM_LONG:
- {
- AST tmp36_AST_in = (AST)_t;
- match(_t,NUM_LONG);
- _t = _t.getNextSibling();
- break;
- }
- case QUOTED_STRING:
- {
- AST tmp37_AST_in = (AST)_t;
- match(_t,QUOTED_STRING);
- _t = _t.getNextSibling();
- break;
- }
- case CONSTANT:
- {
- AST tmp38_AST_in = (AST)_t;
- match(_t,CONSTANT);
- _t = _t.getNextSibling();
- break;
- }
- case JAVA_CONSTANT:
- {
- AST tmp39_AST_in = (AST)_t;
- match(_t,JAVA_CONSTANT);
- _t = _t.getNextSibling();
- break;
- }
- case TRUE:
- {
- AST tmp40_AST_in = (AST)_t;
- match(_t,TRUE);
- _t = _t.getNextSibling();
- break;
- }
- case FALSE:
- {
- AST tmp41_AST_in = (AST)_t;
- match(_t,FALSE);
- _t = _t.getNextSibling();
- break;
- }
- case IDENT:
- {
- AST tmp42_AST_in = (AST)_t;
- match(_t,IDENT);
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void arithmeticExpr(AST _t) throws RecognitionException {
-
- AST arithmeticExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case PLUS:
- case MINUS:
- {
- additiveExpr(_t);
- _t = _retTree;
- break;
- }
- case STAR:
- case DIV:
- {
- multiplicativeExpr(_t);
- _t = _retTree;
- break;
- }
- case UNARY_MINUS:
- {
- AST __t128 = _t;
- AST tmp43_AST_in = (AST)_t;
- match(_t,UNARY_MINUS);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("-");
- }
- expr(_t);
- _t = _retTree;
- _t = __t128;
- _t = _t.getNextSibling();
- break;
- }
- case CASE:
- case CASE2:
- {
- caseExpr(_t);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void countExpr(AST _t) throws RecognitionException {
-
- AST countExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ROW_STAR:
- {
- AST tmp44_AST_in = (AST)_t;
- match(_t,ROW_STAR);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out("*");
- }
- break;
- }
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- simpleExpr(_t);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void simpleExpr(AST _t) throws RecognitionException {
-
- AST simpleExpr_AST_in = (AST)_t;
- AST c = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case FALSE:
- case TRUE:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- {
- c = _t==ASTNULL ? null : (AST)_t;
- constant(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(c);
- }
- break;
- }
- case NULL:
- {
- AST tmp45_AST_in = (AST)_t;
- match(_t,NULL);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out("null");
- }
- break;
- }
- case DOT:
- case INDEX_OP:
- case ALIAS_REF:
- {
- addrExpr(_t);
- _t = _retTree;
- break;
- }
- case SQL_TOKEN:
- {
- sqlToken(_t);
- _t = _retTree;
- break;
- }
- case AGGREGATE:
- {
- aggregate(_t);
- _t = _retTree;
- break;
- }
- case METHOD_CALL:
- {
- methodCall(_t);
- _t = _retTree;
- break;
- }
- case COUNT:
- {
- count(_t);
- _t = _retTree;
- break;
- }
- case PARAM:
- case NAMED_PARAM:
- {
- parameter(_t);
- _t = _retTree;
- break;
- }
- case CASE:
- case CASE2:
- case UNARY_MINUS:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- {
- arithmeticExpr(_t);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void tableJoin(AST _t,
- AST parent
- ) throws RecognitionException {
-
- AST tableJoin_AST_in = (AST)_t;
- AST c = null;
- AST d = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case JOIN_FRAGMENT:
- {
- AST __t77 = _t;
- c = _t==ASTNULL ? null :(AST)_t;
- match(_t,JOIN_FRAGMENT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" "); out(c);
- }
- {
- _loop79:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
- tableJoin(_t, c );
- _t = _retTree;
- }
- else {
- break _loop79;
- }
-
- } while (true);
- }
- _t = __t77;
- _t = _t.getNextSibling();
- break;
- }
- case FROM_FRAGMENT:
- {
- AST __t80 = _t;
- d = _t==ASTNULL ? null :(AST)_t;
- match(_t,FROM_FRAGMENT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- nestedFromFragment(d,parent);
- }
- {
- _loop82:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
- tableJoin(_t, d );
- _t = _retTree;
- }
- else {
- break _loop82;
- }
-
- } while (true);
- }
- _t = __t80;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void booleanOp(AST _t,
- boolean parens
- ) throws RecognitionException {
-
- AST booleanOp_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case AND:
- {
- AST __t84 = _t;
- AST tmp46_AST_in = (AST)_t;
- match(_t,AND);
- _t = _t.getFirstChild();
- booleanExpr(_t,true);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- booleanExpr(_t,true);
- _t = _retTree;
- _t = __t84;
- _t = _t.getNextSibling();
- break;
- }
- case OR:
- {
- AST __t85 = _t;
- AST tmp47_AST_in = (AST)_t;
- match(_t,OR);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- if (parens) out("(");
- }
- booleanExpr(_t,false);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" or ");
- }
- booleanExpr(_t,false);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- if (parens) out(")");
- }
- _t = __t85;
- _t = _t.getNextSibling();
- break;
- }
- case NOT:
- {
- AST __t86 = _t;
- AST tmp48_AST_in = (AST)_t;
- match(_t,NOT);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" not (");
- }
- booleanExpr(_t,false);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- _t = __t86;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void binaryComparisonExpression(AST _t) throws RecognitionException {
-
- AST binaryComparisonExpression_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case EQ:
- {
- AST __t90 = _t;
- AST tmp49_AST_in = (AST)_t;
- match(_t,EQ);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("=");
- }
- expr(_t);
- _t = _retTree;
- _t = __t90;
- _t = _t.getNextSibling();
- break;
- }
- case NE:
- {
- AST __t91 = _t;
- AST tmp50_AST_in = (AST)_t;
- match(_t,NE);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("<>");
- }
- expr(_t);
- _t = _retTree;
- _t = __t91;
- _t = _t.getNextSibling();
- break;
- }
- case GT:
- {
- AST __t92 = _t;
- AST tmp51_AST_in = (AST)_t;
- match(_t,GT);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(">");
- }
- expr(_t);
- _t = _retTree;
- _t = __t92;
- _t = _t.getNextSibling();
- break;
- }
- case GE:
- {
- AST __t93 = _t;
- AST tmp52_AST_in = (AST)_t;
- match(_t,GE);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(">=");
- }
- expr(_t);
- _t = _retTree;
- _t = __t93;
- _t = _t.getNextSibling();
- break;
- }
- case LT:
- {
- AST __t94 = _t;
- AST tmp53_AST_in = (AST)_t;
- match(_t,LT);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("<");
- }
- expr(_t);
- _t = _retTree;
- _t = __t94;
- _t = _t.getNextSibling();
- break;
- }
- case LE:
- {
- AST __t95 = _t;
- AST tmp54_AST_in = (AST)_t;
- match(_t,LE);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("<=");
- }
- expr(_t);
- _t = _retTree;
- _t = __t95;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void exoticComparisonExpression(AST _t) throws RecognitionException {
-
- AST exoticComparisonExpression_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case LIKE:
- {
- AST __t97 = _t;
- AST tmp55_AST_in = (AST)_t;
- match(_t,LIKE);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" like ");
- }
- expr(_t);
- _t = _retTree;
- likeEscape(_t);
- _t = _retTree;
- _t = __t97;
- _t = _t.getNextSibling();
- break;
- }
- case NOT_LIKE:
- {
- AST __t98 = _t;
- AST tmp56_AST_in = (AST)_t;
- match(_t,NOT_LIKE);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" not like ");
- }
- expr(_t);
- _t = _retTree;
- likeEscape(_t);
- _t = _retTree;
- _t = __t98;
- _t = _t.getNextSibling();
- break;
- }
- case BETWEEN:
- {
- AST __t99 = _t;
- AST tmp57_AST_in = (AST)_t;
- match(_t,BETWEEN);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" between ");
- }
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t99;
- _t = _t.getNextSibling();
- break;
- }
- case NOT_BETWEEN:
- {
- AST __t100 = _t;
- AST tmp58_AST_in = (AST)_t;
- match(_t,NOT_BETWEEN);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" not between ");
- }
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" and ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t100;
- _t = _t.getNextSibling();
- break;
- }
- case IN:
- {
- AST __t101 = _t;
- AST tmp59_AST_in = (AST)_t;
- match(_t,IN);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" in");
- }
- inList(_t);
- _t = _retTree;
- _t = __t101;
- _t = _t.getNextSibling();
- break;
- }
- case NOT_IN:
- {
- AST __t102 = _t;
- AST tmp60_AST_in = (AST)_t;
- match(_t,NOT_IN);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" not in ");
- }
- inList(_t);
- _t = _retTree;
- _t = __t102;
- _t = _t.getNextSibling();
- break;
- }
- case EXISTS:
- {
- AST __t103 = _t;
- AST tmp61_AST_in = (AST)_t;
- match(_t,EXISTS);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- optionalSpace(); out("exists ");
- }
- quantified(_t);
- _t = _retTree;
- _t = __t103;
- _t = _t.getNextSibling();
- break;
- }
- case IS_NULL:
- {
- AST __t104 = _t;
- AST tmp62_AST_in = (AST)_t;
- match(_t,IS_NULL);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- _t = __t104;
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(" is null");
- }
- break;
- }
- case IS_NOT_NULL:
- {
- AST __t105 = _t;
- AST tmp63_AST_in = (AST)_t;
- match(_t,IS_NOT_NULL);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- _t = __t105;
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(" is not null");
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void likeEscape(AST _t) throws RecognitionException {
-
- AST likeEscape_AST_in = (AST)_t;
-
- try { // for error handling
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ESCAPE:
- {
- AST __t108 = _t;
- AST tmp64_AST_in = (AST)_t;
- match(_t,ESCAPE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" escape ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t108;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void inList(AST _t) throws RecognitionException {
-
- AST inList_AST_in = (AST)_t;
-
- try { // for error handling
- AST __t110 = _t;
- AST tmp65_AST_in = (AST)_t;
- match(_t,IN_LIST);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" ");
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case SELECT:
- {
- parenSelect(_t);
- _t = _retTree;
- break;
- }
- case 3:
- case COUNT:
- case DOT:
- case FALSE:
- case NULL:
- case TRUE:
- case CASE:
- case AGGREGATE:
- case CASE2:
- case INDEX_OP:
- case METHOD_CALL:
- case UNARY_MINUS:
- case CONSTANT:
- case NUM_DOUBLE:
- case NUM_FLOAT:
- case NUM_LONG:
- case JAVA_CONSTANT:
- case PLUS:
- case MINUS:
- case STAR:
- case DIV:
- case PARAM:
- case NUM_INT:
- case QUOTED_STRING:
- case IDENT:
- case ALIAS_REF:
- case SQL_TOKEN:
- case NAMED_PARAM:
- {
- simpleExprList(_t);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- _t = __t110;
- _t = _t.getNextSibling();
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void quantified(AST _t) throws RecognitionException {
-
- AST quantified_AST_in = (AST)_t;
-
- try { // for error handling
- if ( inputState.guessing==0 ) {
- out("(");
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case SQL_TOKEN:
- {
- sqlToken(_t);
- _t = _retTree;
- break;
- }
- case SELECT:
- {
- selectStatement(_t);
- _t = _retTree;
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- if ( inputState.guessing==0 ) {
- out(")");
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void parenSelect(AST _t) throws RecognitionException {
-
- AST parenSelect_AST_in = (AST)_t;
-
- try { // for error handling
- if ( inputState.guessing==0 ) {
- out("(");
- }
- selectStatement(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void simpleExprList(AST _t) throws RecognitionException {
-
- AST simpleExprList_AST_in = (AST)_t;
- AST e = null;
-
- try { // for error handling
- if ( inputState.guessing==0 ) {
- out("(");
- }
- {
- _loop114:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_tokenSet_4.member(_t.getType()))) {
- e = _t==ASTNULL ? null : (AST)_t;
- simpleExpr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- separator(e," , ");
- }
- }
- else {
- break _loop114;
- }
-
- } while (true);
- }
- if ( inputState.guessing==0 ) {
- out(")");
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void addrExpr(AST _t) throws RecognitionException {
-
- AST addrExpr_AST_in = (AST)_t;
- AST r = null;
- AST i = null;
- AST j = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case DOT:
- {
- AST __t166 = _t;
- r = _t==ASTNULL ? null :(AST)_t;
- match(_t,DOT);
- _t = _t.getFirstChild();
- AST tmp66_AST_in = (AST)_t;
- if ( _t==null ) throw new MismatchedTokenException();
- _t = _t.getNextSibling();
- AST tmp67_AST_in = (AST)_t;
- if ( _t==null ) throw new MismatchedTokenException();
- _t = _t.getNextSibling();
- _t = __t166;
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(r);
- }
- break;
- }
- case ALIAS_REF:
- {
- i = (AST)_t;
- match(_t,ALIAS_REF);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(i);
- }
- break;
- }
- case INDEX_OP:
- {
- j = (AST)_t;
- match(_t,INDEX_OP);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(j);
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void parameter(AST _t) throws RecognitionException {
-
- AST parameter_AST_in = (AST)_t;
- AST n = null;
- AST p = null;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case NAMED_PARAM:
- {
- n = (AST)_t;
- match(_t,NAMED_PARAM);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(n);
- }
- break;
- }
- case PARAM:
- {
- p = (AST)_t;
- match(_t,PARAM);
- _t = _t.getNextSibling();
- if ( inputState.guessing==0 ) {
- out(p);
- }
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void additiveExpr(AST _t) throws RecognitionException {
-
- AST additiveExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case PLUS:
- {
- AST __t130 = _t;
- AST tmp68_AST_in = (AST)_t;
- match(_t,PLUS);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("+");
- }
- expr(_t);
- _t = _retTree;
- _t = __t130;
- _t = _t.getNextSibling();
- break;
- }
- case MINUS:
- {
- AST __t131 = _t;
- AST tmp69_AST_in = (AST)_t;
- match(_t,MINUS);
- _t = _t.getFirstChild();
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("-");
- }
- nestedExprAfterMinusDiv(_t);
- _t = _retTree;
- _t = __t131;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void multiplicativeExpr(AST _t) throws RecognitionException {
-
- AST multiplicativeExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case STAR:
- {
- AST __t133 = _t;
- AST tmp70_AST_in = (AST)_t;
- match(_t,STAR);
- _t = _t.getFirstChild();
- nestedExpr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("*");
- }
- nestedExpr(_t);
- _t = _retTree;
- _t = __t133;
- _t = _t.getNextSibling();
- break;
- }
- case DIV:
- {
- AST __t134 = _t;
- AST tmp71_AST_in = (AST)_t;
- match(_t,DIV);
- _t = _t.getFirstChild();
- nestedExpr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out("/");
- }
- nestedExprAfterMinusDiv(_t);
- _t = _retTree;
- _t = __t134;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void caseExpr(AST _t) throws RecognitionException {
-
- AST caseExpr_AST_in = (AST)_t;
-
- try { // for error handling
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case CASE:
- {
- AST __t142 = _t;
- AST tmp72_AST_in = (AST)_t;
- match(_t,CASE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("case");
- }
- {
- int _cnt145=0;
- _loop145:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==WHEN)) {
- AST __t144 = _t;
- AST tmp73_AST_in = (AST)_t;
- match(_t,WHEN);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out( " when ");
- }
- booleanExpr(_t,false);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" then ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t144;
- _t = _t.getNextSibling();
- }
- else {
- if ( _cnt145>=1 ) { break _loop145; } else {throw new NoViableAltException(_t);}
- }
-
- _cnt145++;
- } while (true);
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ELSE:
- {
- AST __t147 = _t;
- AST tmp74_AST_in = (AST)_t;
- match(_t,ELSE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" else ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t147;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- if ( inputState.guessing==0 ) {
- out(" end");
- }
- _t = __t142;
- _t = _t.getNextSibling();
- break;
- }
- case CASE2:
- {
- AST __t148 = _t;
- AST tmp75_AST_in = (AST)_t;
- match(_t,CASE2);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out("case ");
- }
- expr(_t);
- _t = _retTree;
- {
- int _cnt151=0;
- _loop151:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_t.getType()==WHEN)) {
- AST __t150 = _t;
- AST tmp76_AST_in = (AST)_t;
- match(_t,WHEN);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out( " when ");
- }
- expr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(" then ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t150;
- _t = _t.getNextSibling();
- }
- else {
- if ( _cnt151>=1 ) { break _loop151; } else {throw new NoViableAltException(_t);}
- }
-
- _cnt151++;
- } while (true);
- }
- {
- if (_t==null) _t=ASTNULL;
- switch ( _t.getType()) {
- case ELSE:
- {
- AST __t153 = _t;
- AST tmp77_AST_in = (AST)_t;
- match(_t,ELSE);
- _t = _t.getFirstChild();
- if ( inputState.guessing==0 ) {
- out(" else ");
- }
- expr(_t);
- _t = _retTree;
- _t = __t153;
- _t = _t.getNextSibling();
- break;
- }
- case 3:
- {
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- if ( inputState.guessing==0 ) {
- out(" end");
- }
- _t = __t148;
- _t = _t.getNextSibling();
- break;
- }
- default:
- {
- throw new NoViableAltException(_t);
- }
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void nestedExprAfterMinusDiv(AST _t) throws RecognitionException {
-
- AST nestedExprAfterMinusDiv_AST_in = (AST)_t;
-
- try { // for error handling
- boolean synPredMatched140 = false;
- if (((_tokenSet_5.member(_t.getType())))) {
- AST __t140 = _t;
- synPredMatched140 = true;
- inputState.guessing++;
- try {
- {
- arithmeticExpr(_t);
- _t = _retTree;
- }
- }
- catch (RecognitionException pe) {
- synPredMatched140 = false;
- }
- _t = __t140;
- inputState.guessing--;
- }
- if ( synPredMatched140 ) {
- if ( inputState.guessing==0 ) {
- out("(");
- }
- arithmeticExpr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- }
- else if ((_tokenSet_3.member(_t.getType()))) {
- expr(_t);
- _t = _retTree;
- }
- else {
- throw new NoViableAltException(_t);
- }
-
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void nestedExpr(AST _t) throws RecognitionException {
-
- AST nestedExpr_AST_in = (AST)_t;
-
- try { // for error handling
- boolean synPredMatched137 = false;
- if (((_t.getType()==PLUS||_t.getType()==MINUS))) {
- AST __t137 = _t;
- synPredMatched137 = true;
- inputState.guessing++;
- try {
- {
- additiveExpr(_t);
- _t = _retTree;
- }
- }
- catch (RecognitionException pe) {
- synPredMatched137 = false;
- }
- _t = __t137;
- inputState.guessing--;
- }
- if ( synPredMatched137 ) {
- if ( inputState.guessing==0 ) {
- out("(");
- }
- additiveExpr(_t);
- _t = _retTree;
- if ( inputState.guessing==0 ) {
- out(")");
- }
- }
- else if ((_tokenSet_3.member(_t.getType()))) {
- expr(_t);
- _t = _retTree;
- }
- else {
- throw new NoViableAltException(_t);
- }
-
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
- public final void arguments(AST _t) throws RecognitionException {
-
- AST arguments_AST_in = (AST)_t;
-
- try { // for error handling
- expr(_t);
- _t = _retTree;
- {
- _loop163:
- do {
- if (_t==null) _t=ASTNULL;
- if ((_tokenSet_3.member(_t.getType()))) {
- if ( inputState.guessing==0 ) {
- commaBetweenParameters(", ");
- }
- expr(_t);
- _t = _retTree;
- }
- else {
- break _loop163;
- }
-
- } while (true);
- }
- }
- catch (RecognitionException ex) {
- if (inputState.guessing==0) {
- reportError(ex);
- if (_t!=null) {_t = _t.getNextSibling();}
- } else {
- throw ex;
- }
- }
- _retTree = _t;
- }
-
-
- public static final String[] _tokenNames = {
- "<0>",
- "EOF",
- "<2>",
- "NULL_TREE_LOOKAHEAD",
- "\"all\"",
- "\"any\"",
- "\"and\"",
- "\"as\"",
- "\"asc\"",
- "\"avg\"",
- "\"between\"",
- "\"class\"",
- "\"count\"",
- "\"delete\"",
- "\"desc\"",
- "DOT",
- "\"distinct\"",
- "\"elements\"",
- "\"escape\"",
- "\"exists\"",
- "\"false\"",
- "\"fetch\"",
- "\"from\"",
- "\"full\"",
- "\"group\"",
- "\"having\"",
- "\"in\"",
- "\"indices\"",
- "\"inner\"",
- "\"insert\"",
- "\"into\"",
- "\"is\"",
- "\"join\"",
- "\"left\"",
- "\"like\"",
- "\"max\"",
- "\"min\"",
- "\"new\"",
- "\"not\"",
- "\"null\"",
- "\"or\"",
- "\"order\"",
- "\"outer\"",
- "\"properties\"",
- "\"right\"",
- "\"select\"",
- "\"set\"",
- "\"some\"",
- "\"sum\"",
- "\"true\"",
- "\"union\"",
- "\"update\"",
- "\"versioned\"",
- "\"where\"",
- "\"case\"",
- "\"end\"",
- "\"else\"",
- "\"then\"",
- "\"when\"",
- "\"on\"",
- "\"with\"",
- "\"both\"",
- "\"empty\"",
- "\"leading\"",
- "\"member\"",
- "\"object\"",
- "\"of\"",
- "\"trailing\"",
- "AGGREGATE",
- "ALIAS",
- "CONSTRUCTOR",
- "CASE2",
- "EXPR_LIST",
- "FILTER_ENTITY",
- "IN_LIST",
- "INDEX_OP",
- "IS_NOT_NULL",
- "IS_NULL",
- "METHOD_CALL",
- "NOT_BETWEEN",
- "NOT_IN",
- "NOT_LIKE",
- "ORDER_ELEMENT",
- "QUERY",
- "RANGE",
- "ROW_STAR",
- "SELECT_FROM",
- "UNARY_MINUS",
- "UNARY_PLUS",
- "VECTOR_EXPR",
- "WEIRD_IDENT",
- "CONSTANT",
- "NUM_DOUBLE",
- "NUM_FLOAT",
- "NUM_LONG",
- "JAVA_CONSTANT",
- "COMMA",
- "EQ",
- "OPEN",
- "CLOSE",
- "\"by\"",
- "\"ascending\"",
- "\"descending\"",
- "NE",
- "SQL_NE",
- "LT",
- "GT",
- "LE",
- "GE",
- "CONCAT",
- "PLUS",
- "MINUS",
- "STAR",
- "DIV",
- "OPEN_BRACKET",
- "CLOSE_BRACKET",
- "COLON",
- "PARAM",
- "NUM_INT",
- "QUOTED_STRING",
- "IDENT",
- "ID_START_LETTER",
- "ID_LETTER",
- "ESCqs",
- "WS",
- "HEX_DIGIT",
- "EXPONENT",
- "FLOAT_SUFFIX",
- "FROM_FRAGMENT",
- "IMPLIED_FROM",
- "JOIN_FRAGMENT",
- "SELECT_CLAUSE",
- "LEFT_OUTER",
- "RIGHT_OUTER",
- "ALIAS_REF",
- "PROPERTY_REF",
- "SQL_TOKEN",
- "SELECT_COLUMNS",
- "SELECT_EXPR",
- "THETA_JOINS",
- "FILTERS",
- "METHOD_NAME",
- "NAMED_PARAM",
- "BOGUS",
- "SQL_NODE"
- };
-
- private static final long[] mk_tokenSet_0() {
- long[] data = { 18612532836077568L, 136163524152934608L, 66880L, 0L, 0L, 0L};
- return data;
- }
- public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
- private static final long[] mk_tokenSet_1() {
- long[] data = { 17247503360L, 33543694823424L, 0L, 0L};
- return data;
- }
- public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
- private static final long[] mk_tokenSet_2() {
- long[] data = { 1391637038144L, 33543694823424L, 256L, 0L, 0L, 0L};
- return data;
- }
- public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
- private static final long[] mk_tokenSet_3() {
- long[] data = { 18753820080246832L, 136163524186491024L, 16704L, 0L, 0L, 0L};
- return data;
- }
- public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
- private static final long[] mk_tokenSet_4() {
- long[] data = { 18577898219802624L, 136163524152936592L, 16704L, 0L, 0L, 0L};
- return data;
- }
- public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
- private static final long[] mk_tokenSet_5() {
- long[] data = { 18014398509481984L, 1055531171053696L, 0L, 0L};
- return data;
- }
- public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
- }
-
Deleted: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java 2009-08-03 02:58:24 UTC (rev 17224)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java 2009-08-03 03:14:57 UTC (rev 17225)
@@ -1,154 +0,0 @@
-// $ANTLR 2.7.2: "sql-gen.g" -> "SqlGeneratorBase.java"$
-
-// $Id: sql-gen.g 15746 2009-01-06 17:14:14Z cbredesen $
-package org.hibernate.hql.antlr;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-public interface SqlTokenTypes {
- int EOF = 1;
- int NULL_TREE_LOOKAHEAD = 3;
- int ALL = 4;
- int ANY = 5;
- int AND = 6;
- int AS = 7;
- int ASCENDING = 8;
- int AVG = 9;
- int BETWEEN = 10;
- int CLASS = 11;
- int COUNT = 12;
- int DELETE = 13;
- int DESCENDING = 14;
- int DOT = 15;
- int DISTINCT = 16;
- int ELEMENTS = 17;
- int ESCAPE = 18;
- int EXISTS = 19;
- int FALSE = 20;
- int FETCH = 21;
- int FROM = 22;
- int FULL = 23;
- int GROUP = 24;
- int HAVING = 25;
- int IN = 26;
- int INDICES = 27;
- int INNER = 28;
- int INSERT = 29;
- int INTO = 30;
- int IS = 31;
- int JOIN = 32;
- int LEFT = 33;
- int LIKE = 34;
- int MAX = 35;
- int MIN = 36;
- int NEW = 37;
- int NOT = 38;
- int NULL = 39;
- int OR = 40;
- int ORDER = 41;
- int OUTER = 42;
- int PROPERTIES = 43;
- int RIGHT = 44;
- int SELECT = 45;
- int SET = 46;
- int SOME = 47;
- int SUM = 48;
- int TRUE = 49;
- int UNION = 50;
- int UPDATE = 51;
- int VERSIONED = 52;
- int WHERE = 53;
- int CASE = 54;
- int END = 55;
- int ELSE = 56;
- int THEN = 57;
- int WHEN = 58;
- int ON = 59;
- int WITH = 60;
- int BOTH = 61;
- int EMPTY = 62;
- int LEADING = 63;
- int MEMBER = 64;
- int OBJECT = 65;
- int OF = 66;
- int TRAILING = 67;
- int AGGREGATE = 68;
- int ALIAS = 69;
- int CONSTRUCTOR = 70;
- int CASE2 = 71;
- int EXPR_LIST = 72;
- int FILTER_ENTITY = 73;
- int IN_LIST = 74;
- int INDEX_OP = 75;
- int IS_NOT_NULL = 76;
- int IS_NULL = 77;
- int METHOD_CALL = 78;
- int NOT_BETWEEN = 79;
- int NOT_IN = 80;
- int NOT_LIKE = 81;
- int ORDER_ELEMENT = 82;
- int QUERY = 83;
- int RANGE = 84;
- int ROW_STAR = 85;
- int SELECT_FROM = 86;
- int UNARY_MINUS = 87;
- int UNARY_PLUS = 88;
- int VECTOR_EXPR = 89;
- int WEIRD_IDENT = 90;
- int CONSTANT = 91;
- int NUM_DOUBLE = 92;
- int NUM_FLOAT = 93;
- int NUM_LONG = 94;
- int JAVA_CONSTANT = 95;
- int COMMA = 96;
- int EQ = 97;
- int OPEN = 98;
- int CLOSE = 99;
- int LITERAL_by = 100;
- int LITERAL_ascending = 101;
- int LITERAL_descending = 102;
- int NE = 103;
- int SQL_NE = 104;
- int LT = 105;
- int GT = 106;
- int LE = 107;
- int GE = 108;
- int CONCAT = 109;
- int PLUS = 110;
- int MINUS = 111;
- int STAR = 112;
- int DIV = 113;
- int OPEN_BRACKET = 114;
- int CLOSE_BRACKET = 115;
- int COLON = 116;
- int PARAM = 117;
- int NUM_INT = 118;
- int QUOTED_STRING = 119;
- int IDENT = 120;
- int ID_START_LETTER = 121;
- int ID_LETTER = 122;
- int ESCqs = 123;
- int WS = 124;
- int HEX_DIGIT = 125;
- int EXPONENT = 126;
- int FLOAT_SUFFIX = 127;
- int FROM_FRAGMENT = 128;
- int IMPLIED_FROM = 129;
- int JOIN_FRAGMENT = 130;
- int SELECT_CLAUSE = 131;
- int LEFT_OUTER = 132;
- int RIGHT_OUTER = 133;
- int ALIAS_REF = 134;
- int PROPERTY_REF = 135;
- int SQL_TOKEN = 136;
- int SELECT_COLUMNS = 137;
- int SELECT_EXPR = 138;
- int THETA_JOINS = 139;
- int FILTERS = 140;
- int METHOD_NAME = 141;
- int NAMED_PARAM = 142;
- int BOGUS = 143;
- int SQL_NODE = 144;
-}
Deleted: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt 2009-08-03 02:58:24 UTC (rev 17224)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt 2009-08-03 03:14:57 UTC (rev 17225)
@@ -1,143 +0,0 @@
-// $ANTLR 2.7.2: sql-gen.g -> SqlTokenTypes.txt$
-Sql // output token vocab name
-ALL="all"=4
-ANY="any"=5
-AND="and"=6
-AS="as"=7
-ASCENDING="asc"=8
-AVG="avg"=9
-BETWEEN="between"=10
-CLASS="class"=11
-COUNT="count"=12
-DELETE="delete"=13
-DESCENDING="desc"=14
-DOT=15
-DISTINCT="distinct"=16
-ELEMENTS="elements"=17
-ESCAPE="escape"=18
-EXISTS="exists"=19
-FALSE="false"=20
-FETCH="fetch"=21
-FROM="from"=22
-FULL="full"=23
-GROUP="group"=24
-HAVING="having"=25
-IN="in"=26
-INDICES="indices"=27
-INNER="inner"=28
-INSERT="insert"=29
-INTO="into"=30
-IS="is"=31
-JOIN="join"=32
-LEFT="left"=33
-LIKE="like"=34
-MAX="max"=35
-MIN="min"=36
-NEW="new"=37
-NOT="not"=38
-NULL="null"=39
-OR="or"=40
-ORDER="order"=41
-OUTER="outer"=42
-PROPERTIES="properties"=43
-RIGHT="right"=44
-SELECT="select"=45
-SET="set"=46
-SOME="some"=47
-SUM="sum"=48
-TRUE="true"=49
-UNION="union"=50
-UPDATE="update"=51
-VERSIONED="versioned"=52
-WHERE="where"=53
-CASE="case"=54
-END="end"=55
-ELSE="else"=56
-THEN="then"=57
-WHEN="when"=58
-ON="on"=59
-WITH="with"=60
-BOTH="both"=61
-EMPTY="empty"=62
-LEADING="leading"=63
-MEMBER="member"=64
-OBJECT="object"=65
-OF="of"=66
-TRAILING="trailing"=67
-AGGREGATE=68
-ALIAS=69
-CONSTRUCTOR=70
-CASE2=71
-EXPR_LIST=72
-FILTER_ENTITY=73
-IN_LIST=74
-INDEX_OP=75
-IS_NOT_NULL=76
-IS_NULL=77
-METHOD_CALL=78
-NOT_BETWEEN=79
-NOT_IN=80
-NOT_LIKE=81
-ORDER_ELEMENT=82
-QUERY=83
-RANGE=84
-ROW_STAR=85
-SELECT_FROM=86
-UNARY_MINUS=87
-UNARY_PLUS=88
-VECTOR_EXPR=89
-WEIRD_IDENT=90
-CONSTANT=91
-NUM_DOUBLE=92
-NUM_FLOAT=93
-NUM_LONG=94
-JAVA_CONSTANT=95
-COMMA=96
-EQ=97
-OPEN=98
-CLOSE=99
-LITERAL_by="by"=100
-LITERAL_ascending="ascending"=101
-LITERAL_descending="descending"=102
-NE=103
-SQL_NE=104
-LT=105
-GT=106
-LE=107
-GE=108
-CONCAT=109
-PLUS=110
-MINUS=111
-STAR=112
-DIV=113
-OPEN_BRACKET=114
-CLOSE_BRACKET=115
-COLON=116
-PARAM=117
-NUM_INT=118
-QUOTED_STRING=119
-IDENT=120
-ID_START_LETTER=121
-ID_LETTER=122
-ESCqs=123
-WS=124
-HEX_DIGIT=125
-EXPONENT=126
-FLOAT_SUFFIX=127
-FROM_FRAGMENT=128
-IMPLIED_FROM=129
-JOIN_FRAGMENT=130
-SELECT_CLAUSE=131
-LEFT_OUTER=132
-RIGHT_OUTER=133
-ALIAS_REF=134
-PROPERTY_REF=135
-SQL_TOKEN=136
-SELECT_COLUMNS=137
-SELECT_EXPR=138
-THETA_JOINS=139
-FILTERS=140
-METHOD_NAME=141
-NAMED_PARAM=142
-BOGUS=143
-SQL_NODE=144
14 years, 9 months
Hibernate SVN: r17224 - in core/branches/Branch_3_2_4_SP1_CP: src/org/hibernate/hql/ast and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: stliu
Date: 2009-08-02 22:58:24 -0400 (Sun, 02 Aug 2009)
New Revision: 17224
Added:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/UnaryLogicOperatorNode.java
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
Back-ported HHH-2826 for JBPAPP-2049 IS [NOT] NULL checks with component values
Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -0,0 +1,3887 @@
+// $ANTLR 2.7.2: "sql-gen.g" -> "SqlGeneratorBase.java"$
+
+// $Id: sql-gen.g 15746 2009-01-06 17:14:14Z cbredesen $
+package org.hibernate.hql.antlr;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+import antlr.TreeParser;
+import antlr.Token;
+import antlr.collections.AST;
+import antlr.RecognitionException;
+import antlr.ANTLRException;
+import antlr.NoViableAltException;
+import antlr.MismatchedTokenException;
+import antlr.SemanticException;
+import antlr.collections.impl.BitSet;
+import antlr.ASTPair;
+import antlr.collections.impl.ASTArray;
+
+
+/**
+ * SQL Generator Tree Parser, providing SQL rendering of SQL ASTs produced by the previous phase, HqlSqlWalker. All
+ * syntax decoration such as extra spaces, lack of spaces, extra parens, etc. should be added by this class.
+ * <br>
+ * This grammar processes the HQL/SQL AST and produces an SQL string. The intent is to move dialect-specific
+ * code into a sub-class that will override some of the methods, just like the other two grammars in this system.
+ * @author Joshua Davis (joshua(a)hibernate.org)
+ */
+public class SqlGeneratorBase extends antlr.TreeParser implements SqlTokenTypes
+ {
+
+ private static Log log = LogFactory.getLog(SqlGeneratorBase.class);
+
+ /** the buffer resulting SQL statement is written to */
+ private StringBuffer buf = new StringBuffer();
+
+ protected void out(String s) {
+ buf.append(s);
+ }
+
+ /**
+ * Returns the last character written to the output, or -1 if there isn't one.
+ */
+ protected int getLastChar() {
+ int len = buf.length();
+ if ( len == 0 )
+ return -1;
+ else
+ return buf.charAt( len - 1 );
+ }
+
+ /**
+ * Add a aspace if the previous token was not a space or a parenthesis.
+ */
+ protected void optionalSpace() {
+ // Implemented in the sub-class.
+ }
+
+ protected void out(AST n) {
+ out(n.getText());
+ }
+
+ protected void separator(AST n, String sep) {
+ if (n.getNextSibling() != null)
+ out(sep);
+ }
+
+ protected boolean hasText(AST a) {
+ String t = a.getText();
+ return t != null && t.length() > 0;
+ }
+
+ protected void fromFragmentSeparator(AST a) {
+ // moved this impl into the subclass...
+ }
+
+ protected void nestedFromFragment(AST d,AST parent) {
+ // moved this impl into the subclass...
+ }
+
+ protected StringBuffer getStringBuffer() {
+ return buf;
+ }
+
+ protected void nyi(AST n) {
+ throw new UnsupportedOperationException("Unsupported node: " + n);
+ }
+
+ protected void beginFunctionTemplate(AST m,AST i) {
+ // if template is null we just write the function out as it appears in the hql statement
+ out(i);
+ out("(");
+ }
+
+ protected void endFunctionTemplate(AST m) {
+ out(")");
+ }
+
+ protected void commaBetweenParameters(String comma) {
+ out(comma);
+ }
+public SqlGeneratorBase() {
+ tokenNames = _tokenNames;
+}
+
+ public final void statement(AST _t) throws RecognitionException {
+
+ AST statement_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case SELECT:
+ {
+ selectStatement(_t);
+ _t = _retTree;
+ break;
+ }
+ case UPDATE:
+ {
+ updateStatement(_t);
+ _t = _retTree;
+ break;
+ }
+ case DELETE:
+ {
+ deleteStatement(_t);
+ _t = _retTree;
+ break;
+ }
+ case INSERT:
+ {
+ insertStatement(_t);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void selectStatement(AST _t) throws RecognitionException {
+
+ AST selectStatement_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t3 = _t;
+ AST tmp1_AST_in = (AST)_t;
+ match(_t,SELECT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("select ");
+ }
+ selectClause(_t);
+ _t = _retTree;
+ from(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case WHERE:
+ {
+ AST __t5 = _t;
+ AST tmp2_AST_in = (AST)_t;
+ match(_t,WHERE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" where ");
+ }
+ whereExpr(_t);
+ _t = _retTree;
+ _t = __t5;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ case GROUP:
+ case ORDER:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case GROUP:
+ {
+ AST __t7 = _t;
+ AST tmp3_AST_in = (AST)_t;
+ match(_t,GROUP);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" group by ");
+ }
+ groupExprs(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case HAVING:
+ {
+ AST __t9 = _t;
+ AST tmp4_AST_in = (AST)_t;
+ match(_t,HAVING);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" having ");
+ }
+ booleanExpr(_t,false);
+ _t = _retTree;
+ _t = __t9;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ _t = __t7;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ case ORDER:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ORDER:
+ {
+ AST __t11 = _t;
+ AST tmp5_AST_in = (AST)_t;
+ match(_t,ORDER);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" order by ");
+ }
+ orderExprs(_t);
+ _t = _retTree;
+ _t = __t11;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ _t = __t3;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void updateStatement(AST _t) throws RecognitionException {
+
+ AST updateStatement_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t13 = _t;
+ AST tmp6_AST_in = (AST)_t;
+ match(_t,UPDATE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("update ");
+ }
+ AST __t14 = _t;
+ AST tmp7_AST_in = (AST)_t;
+ match(_t,FROM);
+ _t = _t.getFirstChild();
+ fromTable(_t);
+ _t = _retTree;
+ _t = __t14;
+ _t = _t.getNextSibling();
+ setClause(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case WHERE:
+ {
+ whereClause(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ _t = __t13;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void deleteStatement(AST _t) throws RecognitionException {
+
+ AST deleteStatement_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t17 = _t;
+ AST tmp8_AST_in = (AST)_t;
+ match(_t,DELETE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("delete");
+ }
+ from(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case WHERE:
+ {
+ whereClause(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ _t = __t17;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void insertStatement(AST _t) throws RecognitionException {
+
+ AST insertStatement_AST_in = (AST)_t;
+ AST i = null;
+
+ try { // for error handling
+ AST __t20 = _t;
+ AST tmp9_AST_in = (AST)_t;
+ match(_t,INSERT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out( "insert " );
+ }
+ i = (AST)_t;
+ match(_t,INTO);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out( i ); out( " " );
+ }
+ selectStatement(_t);
+ _t = _retTree;
+ _t = __t20;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void selectClause(AST _t) throws RecognitionException {
+
+ AST selectClause_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t48 = _t;
+ AST tmp10_AST_in = (AST)_t;
+ match(_t,SELECT_CLAUSE);
+ _t = _t.getFirstChild();
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ALL:
+ case DISTINCT:
+ {
+ distinctOrAll(_t);
+ _t = _retTree;
+ break;
+ }
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case SELECT:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CONSTRUCTOR:
+ case CASE2:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case SELECT_EXPR:
+ case SQL_NODE:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ int _cnt51=0;
+ _loop51:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_0.member(_t.getType()))) {
+ selectColumn(_t);
+ _t = _retTree;
+ }
+ else {
+ if ( _cnt51>=1 ) { break _loop51; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt51++;
+ } while (true);
+ }
+ _t = __t48;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void from(AST _t) throws RecognitionException {
+
+ AST from_AST_in = (AST)_t;
+ AST f = null;
+
+ try { // for error handling
+ AST __t66 = _t;
+ f = _t==ASTNULL ? null :(AST)_t;
+ match(_t,FROM);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" from ");
+ }
+ {
+ _loop68:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
+ fromTable(_t);
+ _t = _retTree;
+ }
+ else {
+ break _loop68;
+ }
+
+ } while (true);
+ }
+ _t = __t66;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void whereExpr(AST _t) throws RecognitionException {
+
+ AST whereExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case FILTERS:
+ {
+ filters(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case THETA_JOINS:
+ {
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ thetaJoins(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ case AND:
+ case BETWEEN:
+ case EXISTS:
+ case IN:
+ case LIKE:
+ case NOT:
+ case OR:
+ case IS_NOT_NULL:
+ case IS_NULL:
+ case NOT_BETWEEN:
+ case NOT_IN:
+ case NOT_LIKE:
+ case EQ:
+ case NE:
+ case LT:
+ case GT:
+ case LE:
+ case GE:
+ case SQL_TOKEN:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case AND:
+ case BETWEEN:
+ case EXISTS:
+ case IN:
+ case LIKE:
+ case NOT:
+ case OR:
+ case IS_NOT_NULL:
+ case IS_NULL:
+ case NOT_BETWEEN:
+ case NOT_IN:
+ case NOT_LIKE:
+ case EQ:
+ case NE:
+ case LT:
+ case GT:
+ case LE:
+ case GE:
+ case SQL_TOKEN:
+ {
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ booleanExpr(_t, true );
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ break;
+ }
+ case THETA_JOINS:
+ {
+ thetaJoins(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case AND:
+ case BETWEEN:
+ case EXISTS:
+ case IN:
+ case LIKE:
+ case NOT:
+ case OR:
+ case IS_NOT_NULL:
+ case IS_NULL:
+ case NOT_BETWEEN:
+ case NOT_IN:
+ case NOT_LIKE:
+ case EQ:
+ case NE:
+ case LT:
+ case GT:
+ case LE:
+ case GE:
+ case SQL_TOKEN:
+ {
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ booleanExpr(_t, true );
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ break;
+ }
+ case AND:
+ case BETWEEN:
+ case EXISTS:
+ case IN:
+ case LIKE:
+ case NOT:
+ case OR:
+ case IS_NOT_NULL:
+ case IS_NULL:
+ case NOT_BETWEEN:
+ case NOT_IN:
+ case NOT_LIKE:
+ case EQ:
+ case NE:
+ case LT:
+ case GT:
+ case LE:
+ case GE:
+ case SQL_TOKEN:
+ {
+ booleanExpr(_t,false);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void groupExprs(AST _t) throws RecognitionException {
+
+ AST groupExprs_AST_in = (AST)_t;
+
+ try { // for error handling
+ expr(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ALL:
+ case ANY:
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case SELECT:
+ case SOME:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case VECTOR_EXPR:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ if ( inputState.guessing==0 ) {
+ out(" , ");
+ }
+ groupExprs(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ case HAVING:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void booleanExpr(AST _t,
+ boolean parens
+ ) throws RecognitionException {
+
+ AST booleanExpr_AST_in = (AST)_t;
+ AST st = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case AND:
+ case NOT:
+ case OR:
+ {
+ booleanOp(_t, parens );
+ _t = _retTree;
+ break;
+ }
+ case BETWEEN:
+ case EXISTS:
+ case IN:
+ case LIKE:
+ case IS_NOT_NULL:
+ case IS_NULL:
+ case NOT_BETWEEN:
+ case NOT_IN:
+ case NOT_LIKE:
+ case EQ:
+ case NE:
+ case LT:
+ case GT:
+ case LE:
+ case GE:
+ {
+ comparisonExpr(_t, parens );
+ _t = _retTree;
+ break;
+ }
+ case SQL_TOKEN:
+ {
+ st = (AST)_t;
+ match(_t,SQL_TOKEN);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(st);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void orderExprs(AST _t) throws RecognitionException {
+
+ AST orderExprs_AST_in = (AST)_t;
+ AST dir = null;
+
+ try { // for error handling
+ {
+ expr(_t);
+ _t = _retTree;
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ASCENDING:
+ case DESCENDING:
+ {
+ dir = _t==ASTNULL ? null : (AST)_t;
+ orderDirection(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" "); out(dir);
+ }
+ break;
+ }
+ case 3:
+ case ALL:
+ case ANY:
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case SELECT:
+ case SOME:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case VECTOR_EXPR:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ALL:
+ case ANY:
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case SELECT:
+ case SOME:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case VECTOR_EXPR:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ if ( inputState.guessing==0 ) {
+ out(", ");
+ }
+ orderExprs(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void fromTable(AST _t) throws RecognitionException {
+
+ AST fromTable_AST_in = (AST)_t;
+ AST a = null;
+ AST b = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case FROM_FRAGMENT:
+ {
+ AST __t70 = _t;
+ a = _t==ASTNULL ? null :(AST)_t;
+ match(_t,FROM_FRAGMENT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(a);
+ }
+ {
+ _loop72:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
+ tableJoin(_t, a );
+ _t = _retTree;
+ }
+ else {
+ break _loop72;
+ }
+
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ fromFragmentSeparator(a);
+ }
+ _t = __t70;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case JOIN_FRAGMENT:
+ {
+ AST __t73 = _t;
+ b = _t==ASTNULL ? null :(AST)_t;
+ match(_t,JOIN_FRAGMENT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(b);
+ }
+ {
+ _loop75:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
+ tableJoin(_t, b );
+ _t = _retTree;
+ }
+ else {
+ break _loop75;
+ }
+
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ fromFragmentSeparator(b);
+ }
+ _t = __t73;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void setClause(AST _t) throws RecognitionException {
+
+ AST setClause_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t22 = _t;
+ AST tmp11_AST_in = (AST)_t;
+ match(_t,SET);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" set ");
+ }
+ comparisonExpr(_t,false);
+ _t = _retTree;
+ {
+ _loop24:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_1.member(_t.getType()))) {
+ if ( inputState.guessing==0 ) {
+ out(", ");
+ }
+ comparisonExpr(_t,false);
+ _t = _retTree;
+ }
+ else {
+ break _loop24;
+ }
+
+ } while (true);
+ }
+ _t = __t22;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void whereClause(AST _t) throws RecognitionException {
+
+ AST whereClause_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t26 = _t;
+ AST tmp12_AST_in = (AST)_t;
+ match(_t,WHERE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" where ");
+ }
+ whereClauseExpr(_t);
+ _t = _retTree;
+ _t = __t26;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void comparisonExpr(AST _t,
+ boolean parens
+ ) throws RecognitionException {
+
+ AST comparisonExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case EQ:
+ case NE:
+ case LT:
+ case GT:
+ case LE:
+ case GE:
+ {
+ binaryComparisonExpression(_t);
+ _t = _retTree;
+ break;
+ }
+ case BETWEEN:
+ case EXISTS:
+ case IN:
+ case LIKE:
+ case IS_NOT_NULL:
+ case IS_NULL:
+ case NOT_BETWEEN:
+ case NOT_IN:
+ case NOT_LIKE:
+ {
+ if ( inputState.guessing==0 ) {
+ if (parens) out("(");
+ }
+ exoticComparisonExpression(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ if (parens) out(")");
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void whereClauseExpr(AST _t) throws RecognitionException {
+
+ AST whereClauseExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ boolean synPredMatched29 = false;
+ if (((_t.getType()==SQL_TOKEN))) {
+ AST __t29 = _t;
+ synPredMatched29 = true;
+ inputState.guessing++;
+ try {
+ {
+ AST tmp13_AST_in = (AST)_t;
+ match(_t,SQL_TOKEN);
+ _t = _t.getNextSibling();
+ }
+ }
+ catch (RecognitionException pe) {
+ synPredMatched29 = false;
+ }
+ _t = __t29;
+ inputState.guessing--;
+ }
+ if ( synPredMatched29 ) {
+ conditionList(_t);
+ _t = _retTree;
+ }
+ else if ((_tokenSet_2.member(_t.getType()))) {
+ booleanExpr(_t, false );
+ _t = _retTree;
+ }
+ else {
+ throw new NoViableAltException(_t);
+ }
+
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void conditionList(AST _t) throws RecognitionException {
+
+ AST conditionList_AST_in = (AST)_t;
+
+ try { // for error handling
+ sqlToken(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case SQL_TOKEN:
+ {
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ conditionList(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void expr(AST _t) throws RecognitionException {
+
+ AST expr_AST_in = (AST)_t;
+ AST e = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ simpleExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ case VECTOR_EXPR:
+ {
+ AST __t116 = _t;
+ AST tmp14_AST_in = (AST)_t;
+ match(_t,VECTOR_EXPR);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ {
+ _loop118:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_3.member(_t.getType()))) {
+ e = _t==ASTNULL ? null : (AST)_t;
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ separator(e," , ");
+ }
+ }
+ else {
+ break _loop118;
+ }
+
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ _t = __t116;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case SELECT:
+ {
+ parenSelect(_t);
+ _t = _retTree;
+ break;
+ }
+ case ANY:
+ {
+ AST __t119 = _t;
+ AST tmp15_AST_in = (AST)_t;
+ match(_t,ANY);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("any ");
+ }
+ quantified(_t);
+ _t = _retTree;
+ _t = __t119;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case ALL:
+ {
+ AST __t120 = _t;
+ AST tmp16_AST_in = (AST)_t;
+ match(_t,ALL);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("all ");
+ }
+ quantified(_t);
+ _t = _retTree;
+ _t = __t120;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case SOME:
+ {
+ AST __t121 = _t;
+ AST tmp17_AST_in = (AST)_t;
+ match(_t,SOME);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("some ");
+ }
+ quantified(_t);
+ _t = _retTree;
+ _t = __t121;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void orderDirection(AST _t) throws RecognitionException {
+
+ AST orderDirection_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ASCENDING:
+ {
+ AST tmp18_AST_in = (AST)_t;
+ match(_t,ASCENDING);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case DESCENDING:
+ {
+ AST tmp19_AST_in = (AST)_t;
+ match(_t,DESCENDING);
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void filters(AST _t) throws RecognitionException {
+
+ AST filters_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t42 = _t;
+ AST tmp20_AST_in = (AST)_t;
+ match(_t,FILTERS);
+ _t = _t.getFirstChild();
+ conditionList(_t);
+ _t = _retTree;
+ _t = __t42;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void thetaJoins(AST _t) throws RecognitionException {
+
+ AST thetaJoins_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t44 = _t;
+ AST tmp21_AST_in = (AST)_t;
+ match(_t,THETA_JOINS);
+ _t = _t.getFirstChild();
+ conditionList(_t);
+ _t = _retTree;
+ _t = __t44;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void sqlToken(AST _t) throws RecognitionException {
+
+ AST sqlToken_AST_in = (AST)_t;
+ AST t = null;
+
+ try { // for error handling
+ t = (AST)_t;
+ match(_t,SQL_TOKEN);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(t);
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void distinctOrAll(AST _t) throws RecognitionException {
+
+ AST distinctOrAll_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case DISTINCT:
+ {
+ AST tmp22_AST_in = (AST)_t;
+ match(_t,DISTINCT);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out("distinct ");
+ }
+ break;
+ }
+ case ALL:
+ {
+ AST tmp23_AST_in = (AST)_t;
+ match(_t,ALL);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out("all ");
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void selectColumn(AST _t) throws RecognitionException {
+
+ AST selectColumn_AST_in = (AST)_t;
+ AST p = null;
+ AST sc = null;
+
+ try { // for error handling
+ p = _t==ASTNULL ? null : (AST)_t;
+ selectExpr(_t);
+ _t = _retTree;
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case SELECT_COLUMNS:
+ {
+ sc = (AST)_t;
+ match(_t,SELECT_COLUMNS);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(sc);
+ }
+ break;
+ }
+ case 3:
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case SELECT:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CONSTRUCTOR:
+ case CASE2:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case SELECT_EXPR:
+ case SQL_NODE:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ separator( (sc != null) ? sc : p,", ");
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void selectExpr(AST _t) throws RecognitionException {
+
+ AST selectExpr_AST_in = (AST)_t;
+ AST e = null;
+ AST c = null;
+ AST param = null;
+ AST sn = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case DOT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case SELECT_EXPR:
+ {
+ e = _t==ASTNULL ? null : (AST)_t;
+ selectAtom(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(e);
+ }
+ break;
+ }
+ case COUNT:
+ {
+ count(_t);
+ _t = _retTree;
+ break;
+ }
+ case CONSTRUCTOR:
+ {
+ AST __t55 = _t;
+ AST tmp24_AST_in = (AST)_t;
+ match(_t,CONSTRUCTOR);
+ _t = _t.getFirstChild();
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case DOT:
+ {
+ AST tmp25_AST_in = (AST)_t;
+ match(_t,DOT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case IDENT:
+ {
+ AST tmp26_AST_in = (AST)_t;
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ {
+ int _cnt58=0;
+ _loop58:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_0.member(_t.getType()))) {
+ selectColumn(_t);
+ _t = _retTree;
+ }
+ else {
+ if ( _cnt58>=1 ) { break _loop58; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt58++;
+ } while (true);
+ }
+ _t = __t55;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case METHOD_CALL:
+ {
+ methodCall(_t);
+ _t = _retTree;
+ break;
+ }
+ case AGGREGATE:
+ {
+ aggregate(_t);
+ _t = _retTree;
+ break;
+ }
+ case FALSE:
+ case TRUE:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ {
+ c = _t==ASTNULL ? null : (AST)_t;
+ constant(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(c);
+ }
+ break;
+ }
+ case CASE:
+ case CASE2:
+ case UNARY_MINUS:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ {
+ arithmeticExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ case PARAM:
+ {
+ param = (AST)_t;
+ match(_t,PARAM);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(param);
+ }
+ break;
+ }
+ case SQL_NODE:
+ {
+ sn = (AST)_t;
+ match(_t,SQL_NODE);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(sn);
+ }
+ break;
+ }
+ case SELECT:
+ {
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ selectStatement(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void selectAtom(AST _t) throws RecognitionException {
+
+ AST selectAtom_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case DOT:
+ {
+ AST tmp27_AST_in = (AST)_t;
+ match(_t,DOT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case SQL_TOKEN:
+ {
+ AST tmp28_AST_in = (AST)_t;
+ match(_t,SQL_TOKEN);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case ALIAS_REF:
+ {
+ AST tmp29_AST_in = (AST)_t;
+ match(_t,ALIAS_REF);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case SELECT_EXPR:
+ {
+ AST tmp30_AST_in = (AST)_t;
+ match(_t,SELECT_EXPR);
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void count(AST _t) throws RecognitionException {
+
+ AST count_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t60 = _t;
+ AST tmp31_AST_in = (AST)_t;
+ match(_t,COUNT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("count(");
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ALL:
+ case DISTINCT:
+ {
+ distinctOrAll(_t);
+ _t = _retTree;
+ break;
+ }
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case ROW_STAR:
+ case UNARY_MINUS:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ countExpr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ _t = __t60;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void methodCall(AST _t) throws RecognitionException {
+
+ AST methodCall_AST_in = (AST)_t;
+ AST m = null;
+ AST i = null;
+
+ try { // for error handling
+ AST __t157 = _t;
+ m = _t==ASTNULL ? null :(AST)_t;
+ match(_t,METHOD_CALL);
+ _t = _t.getFirstChild();
+ i = (AST)_t;
+ match(_t,METHOD_NAME);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ beginFunctionTemplate(m,i);
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case EXPR_LIST:
+ {
+ AST __t159 = _t;
+ AST tmp32_AST_in = (AST)_t;
+ match(_t,EXPR_LIST);
+ _t = _t.getFirstChild();
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ALL:
+ case ANY:
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case SELECT:
+ case SOME:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case VECTOR_EXPR:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ arguments(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ _t = __t159;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ endFunctionTemplate(m);
+ }
+ _t = __t157;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void aggregate(AST _t) throws RecognitionException {
+
+ AST aggregate_AST_in = (AST)_t;
+ AST a = null;
+
+ try { // for error handling
+ AST __t155 = _t;
+ a = _t==ASTNULL ? null :(AST)_t;
+ match(_t,AGGREGATE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(a); out("(");
+ }
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ _t = __t155;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void constant(AST _t) throws RecognitionException {
+
+ AST constant_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case NUM_DOUBLE:
+ {
+ AST tmp33_AST_in = (AST)_t;
+ match(_t,NUM_DOUBLE);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NUM_FLOAT:
+ {
+ AST tmp34_AST_in = (AST)_t;
+ match(_t,NUM_FLOAT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NUM_INT:
+ {
+ AST tmp35_AST_in = (AST)_t;
+ match(_t,NUM_INT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NUM_LONG:
+ {
+ AST tmp36_AST_in = (AST)_t;
+ match(_t,NUM_LONG);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case QUOTED_STRING:
+ {
+ AST tmp37_AST_in = (AST)_t;
+ match(_t,QUOTED_STRING);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case CONSTANT:
+ {
+ AST tmp38_AST_in = (AST)_t;
+ match(_t,CONSTANT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case JAVA_CONSTANT:
+ {
+ AST tmp39_AST_in = (AST)_t;
+ match(_t,JAVA_CONSTANT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case TRUE:
+ {
+ AST tmp40_AST_in = (AST)_t;
+ match(_t,TRUE);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case FALSE:
+ {
+ AST tmp41_AST_in = (AST)_t;
+ match(_t,FALSE);
+ _t = _t.getNextSibling();
+ break;
+ }
+ case IDENT:
+ {
+ AST tmp42_AST_in = (AST)_t;
+ match(_t,IDENT);
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void arithmeticExpr(AST _t) throws RecognitionException {
+
+ AST arithmeticExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case PLUS:
+ case MINUS:
+ {
+ additiveExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ case STAR:
+ case DIV:
+ {
+ multiplicativeExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ case UNARY_MINUS:
+ {
+ AST __t128 = _t;
+ AST tmp43_AST_in = (AST)_t;
+ match(_t,UNARY_MINUS);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("-");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t128;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case CASE:
+ case CASE2:
+ {
+ caseExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void countExpr(AST _t) throws RecognitionException {
+
+ AST countExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ROW_STAR:
+ {
+ AST tmp44_AST_in = (AST)_t;
+ match(_t,ROW_STAR);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out("*");
+ }
+ break;
+ }
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ simpleExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void simpleExpr(AST _t) throws RecognitionException {
+
+ AST simpleExpr_AST_in = (AST)_t;
+ AST c = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case FALSE:
+ case TRUE:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ {
+ c = _t==ASTNULL ? null : (AST)_t;
+ constant(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(c);
+ }
+ break;
+ }
+ case NULL:
+ {
+ AST tmp45_AST_in = (AST)_t;
+ match(_t,NULL);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out("null");
+ }
+ break;
+ }
+ case DOT:
+ case INDEX_OP:
+ case ALIAS_REF:
+ {
+ addrExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ case SQL_TOKEN:
+ {
+ sqlToken(_t);
+ _t = _retTree;
+ break;
+ }
+ case AGGREGATE:
+ {
+ aggregate(_t);
+ _t = _retTree;
+ break;
+ }
+ case METHOD_CALL:
+ {
+ methodCall(_t);
+ _t = _retTree;
+ break;
+ }
+ case COUNT:
+ {
+ count(_t);
+ _t = _retTree;
+ break;
+ }
+ case PARAM:
+ case NAMED_PARAM:
+ {
+ parameter(_t);
+ _t = _retTree;
+ break;
+ }
+ case CASE:
+ case CASE2:
+ case UNARY_MINUS:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ {
+ arithmeticExpr(_t);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void tableJoin(AST _t,
+ AST parent
+ ) throws RecognitionException {
+
+ AST tableJoin_AST_in = (AST)_t;
+ AST c = null;
+ AST d = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case JOIN_FRAGMENT:
+ {
+ AST __t77 = _t;
+ c = _t==ASTNULL ? null :(AST)_t;
+ match(_t,JOIN_FRAGMENT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" "); out(c);
+ }
+ {
+ _loop79:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
+ tableJoin(_t, c );
+ _t = _retTree;
+ }
+ else {
+ break _loop79;
+ }
+
+ } while (true);
+ }
+ _t = __t77;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case FROM_FRAGMENT:
+ {
+ AST __t80 = _t;
+ d = _t==ASTNULL ? null :(AST)_t;
+ match(_t,FROM_FRAGMENT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ nestedFromFragment(d,parent);
+ }
+ {
+ _loop82:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==FROM_FRAGMENT||_t.getType()==JOIN_FRAGMENT)) {
+ tableJoin(_t, d );
+ _t = _retTree;
+ }
+ else {
+ break _loop82;
+ }
+
+ } while (true);
+ }
+ _t = __t80;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void booleanOp(AST _t,
+ boolean parens
+ ) throws RecognitionException {
+
+ AST booleanOp_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case AND:
+ {
+ AST __t84 = _t;
+ AST tmp46_AST_in = (AST)_t;
+ match(_t,AND);
+ _t = _t.getFirstChild();
+ booleanExpr(_t,true);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ booleanExpr(_t,true);
+ _t = _retTree;
+ _t = __t84;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case OR:
+ {
+ AST __t85 = _t;
+ AST tmp47_AST_in = (AST)_t;
+ match(_t,OR);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ if (parens) out("(");
+ }
+ booleanExpr(_t,false);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" or ");
+ }
+ booleanExpr(_t,false);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ if (parens) out(")");
+ }
+ _t = __t85;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NOT:
+ {
+ AST __t86 = _t;
+ AST tmp48_AST_in = (AST)_t;
+ match(_t,NOT);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" not (");
+ }
+ booleanExpr(_t,false);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ _t = __t86;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void binaryComparisonExpression(AST _t) throws RecognitionException {
+
+ AST binaryComparisonExpression_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case EQ:
+ {
+ AST __t90 = _t;
+ AST tmp49_AST_in = (AST)_t;
+ match(_t,EQ);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("=");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t90;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NE:
+ {
+ AST __t91 = _t;
+ AST tmp50_AST_in = (AST)_t;
+ match(_t,NE);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("<>");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t91;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case GT:
+ {
+ AST __t92 = _t;
+ AST tmp51_AST_in = (AST)_t;
+ match(_t,GT);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(">");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t92;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case GE:
+ {
+ AST __t93 = _t;
+ AST tmp52_AST_in = (AST)_t;
+ match(_t,GE);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(">=");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t93;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case LT:
+ {
+ AST __t94 = _t;
+ AST tmp53_AST_in = (AST)_t;
+ match(_t,LT);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("<");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t94;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case LE:
+ {
+ AST __t95 = _t;
+ AST tmp54_AST_in = (AST)_t;
+ match(_t,LE);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("<=");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t95;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void exoticComparisonExpression(AST _t) throws RecognitionException {
+
+ AST exoticComparisonExpression_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case LIKE:
+ {
+ AST __t97 = _t;
+ AST tmp55_AST_in = (AST)_t;
+ match(_t,LIKE);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" like ");
+ }
+ expr(_t);
+ _t = _retTree;
+ likeEscape(_t);
+ _t = _retTree;
+ _t = __t97;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NOT_LIKE:
+ {
+ AST __t98 = _t;
+ AST tmp56_AST_in = (AST)_t;
+ match(_t,NOT_LIKE);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" not like ");
+ }
+ expr(_t);
+ _t = _retTree;
+ likeEscape(_t);
+ _t = _retTree;
+ _t = __t98;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case BETWEEN:
+ {
+ AST __t99 = _t;
+ AST tmp57_AST_in = (AST)_t;
+ match(_t,BETWEEN);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" between ");
+ }
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t99;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NOT_BETWEEN:
+ {
+ AST __t100 = _t;
+ AST tmp58_AST_in = (AST)_t;
+ match(_t,NOT_BETWEEN);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" not between ");
+ }
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" and ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t100;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case IN:
+ {
+ AST __t101 = _t;
+ AST tmp59_AST_in = (AST)_t;
+ match(_t,IN);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" in");
+ }
+ inList(_t);
+ _t = _retTree;
+ _t = __t101;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case NOT_IN:
+ {
+ AST __t102 = _t;
+ AST tmp60_AST_in = (AST)_t;
+ match(_t,NOT_IN);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" not in ");
+ }
+ inList(_t);
+ _t = _retTree;
+ _t = __t102;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case EXISTS:
+ {
+ AST __t103 = _t;
+ AST tmp61_AST_in = (AST)_t;
+ match(_t,EXISTS);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ optionalSpace(); out("exists ");
+ }
+ quantified(_t);
+ _t = _retTree;
+ _t = __t103;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case IS_NULL:
+ {
+ AST __t104 = _t;
+ AST tmp62_AST_in = (AST)_t;
+ match(_t,IS_NULL);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ _t = __t104;
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(" is null");
+ }
+ break;
+ }
+ case IS_NOT_NULL:
+ {
+ AST __t105 = _t;
+ AST tmp63_AST_in = (AST)_t;
+ match(_t,IS_NOT_NULL);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ _t = __t105;
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(" is not null");
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void likeEscape(AST _t) throws RecognitionException {
+
+ AST likeEscape_AST_in = (AST)_t;
+
+ try { // for error handling
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ESCAPE:
+ {
+ AST __t108 = _t;
+ AST tmp64_AST_in = (AST)_t;
+ match(_t,ESCAPE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" escape ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t108;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void inList(AST _t) throws RecognitionException {
+
+ AST inList_AST_in = (AST)_t;
+
+ try { // for error handling
+ AST __t110 = _t;
+ AST tmp65_AST_in = (AST)_t;
+ match(_t,IN_LIST);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" ");
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case SELECT:
+ {
+ parenSelect(_t);
+ _t = _retTree;
+ break;
+ }
+ case 3:
+ case COUNT:
+ case DOT:
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case CASE:
+ case AGGREGATE:
+ case CASE2:
+ case INDEX_OP:
+ case METHOD_CALL:
+ case UNARY_MINUS:
+ case CONSTANT:
+ case NUM_DOUBLE:
+ case NUM_FLOAT:
+ case NUM_LONG:
+ case JAVA_CONSTANT:
+ case PLUS:
+ case MINUS:
+ case STAR:
+ case DIV:
+ case PARAM:
+ case NUM_INT:
+ case QUOTED_STRING:
+ case IDENT:
+ case ALIAS_REF:
+ case SQL_TOKEN:
+ case NAMED_PARAM:
+ {
+ simpleExprList(_t);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ _t = __t110;
+ _t = _t.getNextSibling();
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void quantified(AST _t) throws RecognitionException {
+
+ AST quantified_AST_in = (AST)_t;
+
+ try { // for error handling
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case SQL_TOKEN:
+ {
+ sqlToken(_t);
+ _t = _retTree;
+ break;
+ }
+ case SELECT:
+ {
+ selectStatement(_t);
+ _t = _retTree;
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void parenSelect(AST _t) throws RecognitionException {
+
+ AST parenSelect_AST_in = (AST)_t;
+
+ try { // for error handling
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ selectStatement(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void simpleExprList(AST _t) throws RecognitionException {
+
+ AST simpleExprList_AST_in = (AST)_t;
+ AST e = null;
+
+ try { // for error handling
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ {
+ _loop114:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_4.member(_t.getType()))) {
+ e = _t==ASTNULL ? null : (AST)_t;
+ simpleExpr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ separator(e," , ");
+ }
+ }
+ else {
+ break _loop114;
+ }
+
+ } while (true);
+ }
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void addrExpr(AST _t) throws RecognitionException {
+
+ AST addrExpr_AST_in = (AST)_t;
+ AST r = null;
+ AST i = null;
+ AST j = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case DOT:
+ {
+ AST __t166 = _t;
+ r = _t==ASTNULL ? null :(AST)_t;
+ match(_t,DOT);
+ _t = _t.getFirstChild();
+ AST tmp66_AST_in = (AST)_t;
+ if ( _t==null ) throw new MismatchedTokenException();
+ _t = _t.getNextSibling();
+ AST tmp67_AST_in = (AST)_t;
+ if ( _t==null ) throw new MismatchedTokenException();
+ _t = _t.getNextSibling();
+ _t = __t166;
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(r);
+ }
+ break;
+ }
+ case ALIAS_REF:
+ {
+ i = (AST)_t;
+ match(_t,ALIAS_REF);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(i);
+ }
+ break;
+ }
+ case INDEX_OP:
+ {
+ j = (AST)_t;
+ match(_t,INDEX_OP);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(j);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void parameter(AST _t) throws RecognitionException {
+
+ AST parameter_AST_in = (AST)_t;
+ AST n = null;
+ AST p = null;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case NAMED_PARAM:
+ {
+ n = (AST)_t;
+ match(_t,NAMED_PARAM);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(n);
+ }
+ break;
+ }
+ case PARAM:
+ {
+ p = (AST)_t;
+ match(_t,PARAM);
+ _t = _t.getNextSibling();
+ if ( inputState.guessing==0 ) {
+ out(p);
+ }
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void additiveExpr(AST _t) throws RecognitionException {
+
+ AST additiveExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case PLUS:
+ {
+ AST __t130 = _t;
+ AST tmp68_AST_in = (AST)_t;
+ match(_t,PLUS);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("+");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t130;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case MINUS:
+ {
+ AST __t131 = _t;
+ AST tmp69_AST_in = (AST)_t;
+ match(_t,MINUS);
+ _t = _t.getFirstChild();
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("-");
+ }
+ nestedExprAfterMinusDiv(_t);
+ _t = _retTree;
+ _t = __t131;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void multiplicativeExpr(AST _t) throws RecognitionException {
+
+ AST multiplicativeExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case STAR:
+ {
+ AST __t133 = _t;
+ AST tmp70_AST_in = (AST)_t;
+ match(_t,STAR);
+ _t = _t.getFirstChild();
+ nestedExpr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("*");
+ }
+ nestedExpr(_t);
+ _t = _retTree;
+ _t = __t133;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case DIV:
+ {
+ AST __t134 = _t;
+ AST tmp71_AST_in = (AST)_t;
+ match(_t,DIV);
+ _t = _t.getFirstChild();
+ nestedExpr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out("/");
+ }
+ nestedExprAfterMinusDiv(_t);
+ _t = _retTree;
+ _t = __t134;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void caseExpr(AST _t) throws RecognitionException {
+
+ AST caseExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case CASE:
+ {
+ AST __t142 = _t;
+ AST tmp72_AST_in = (AST)_t;
+ match(_t,CASE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("case");
+ }
+ {
+ int _cnt145=0;
+ _loop145:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==WHEN)) {
+ AST __t144 = _t;
+ AST tmp73_AST_in = (AST)_t;
+ match(_t,WHEN);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out( " when ");
+ }
+ booleanExpr(_t,false);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" then ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t144;
+ _t = _t.getNextSibling();
+ }
+ else {
+ if ( _cnt145>=1 ) { break _loop145; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt145++;
+ } while (true);
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ELSE:
+ {
+ AST __t147 = _t;
+ AST tmp74_AST_in = (AST)_t;
+ match(_t,ELSE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" else ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t147;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ out(" end");
+ }
+ _t = __t142;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case CASE2:
+ {
+ AST __t148 = _t;
+ AST tmp75_AST_in = (AST)_t;
+ match(_t,CASE2);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out("case ");
+ }
+ expr(_t);
+ _t = _retTree;
+ {
+ int _cnt151=0;
+ _loop151:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_t.getType()==WHEN)) {
+ AST __t150 = _t;
+ AST tmp76_AST_in = (AST)_t;
+ match(_t,WHEN);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out( " when ");
+ }
+ expr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(" then ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t150;
+ _t = _t.getNextSibling();
+ }
+ else {
+ if ( _cnt151>=1 ) { break _loop151; } else {throw new NoViableAltException(_t);}
+ }
+
+ _cnt151++;
+ } while (true);
+ }
+ {
+ if (_t==null) _t=ASTNULL;
+ switch ( _t.getType()) {
+ case ELSE:
+ {
+ AST __t153 = _t;
+ AST tmp77_AST_in = (AST)_t;
+ match(_t,ELSE);
+ _t = _t.getFirstChild();
+ if ( inputState.guessing==0 ) {
+ out(" else ");
+ }
+ expr(_t);
+ _t = _retTree;
+ _t = __t153;
+ _t = _t.getNextSibling();
+ break;
+ }
+ case 3:
+ {
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ if ( inputState.guessing==0 ) {
+ out(" end");
+ }
+ _t = __t148;
+ _t = _t.getNextSibling();
+ break;
+ }
+ default:
+ {
+ throw new NoViableAltException(_t);
+ }
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void nestedExprAfterMinusDiv(AST _t) throws RecognitionException {
+
+ AST nestedExprAfterMinusDiv_AST_in = (AST)_t;
+
+ try { // for error handling
+ boolean synPredMatched140 = false;
+ if (((_tokenSet_5.member(_t.getType())))) {
+ AST __t140 = _t;
+ synPredMatched140 = true;
+ inputState.guessing++;
+ try {
+ {
+ arithmeticExpr(_t);
+ _t = _retTree;
+ }
+ }
+ catch (RecognitionException pe) {
+ synPredMatched140 = false;
+ }
+ _t = __t140;
+ inputState.guessing--;
+ }
+ if ( synPredMatched140 ) {
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ arithmeticExpr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ }
+ else if ((_tokenSet_3.member(_t.getType()))) {
+ expr(_t);
+ _t = _retTree;
+ }
+ else {
+ throw new NoViableAltException(_t);
+ }
+
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void nestedExpr(AST _t) throws RecognitionException {
+
+ AST nestedExpr_AST_in = (AST)_t;
+
+ try { // for error handling
+ boolean synPredMatched137 = false;
+ if (((_t.getType()==PLUS||_t.getType()==MINUS))) {
+ AST __t137 = _t;
+ synPredMatched137 = true;
+ inputState.guessing++;
+ try {
+ {
+ additiveExpr(_t);
+ _t = _retTree;
+ }
+ }
+ catch (RecognitionException pe) {
+ synPredMatched137 = false;
+ }
+ _t = __t137;
+ inputState.guessing--;
+ }
+ if ( synPredMatched137 ) {
+ if ( inputState.guessing==0 ) {
+ out("(");
+ }
+ additiveExpr(_t);
+ _t = _retTree;
+ if ( inputState.guessing==0 ) {
+ out(")");
+ }
+ }
+ else if ((_tokenSet_3.member(_t.getType()))) {
+ expr(_t);
+ _t = _retTree;
+ }
+ else {
+ throw new NoViableAltException(_t);
+ }
+
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+ public final void arguments(AST _t) throws RecognitionException {
+
+ AST arguments_AST_in = (AST)_t;
+
+ try { // for error handling
+ expr(_t);
+ _t = _retTree;
+ {
+ _loop163:
+ do {
+ if (_t==null) _t=ASTNULL;
+ if ((_tokenSet_3.member(_t.getType()))) {
+ if ( inputState.guessing==0 ) {
+ commaBetweenParameters(", ");
+ }
+ expr(_t);
+ _t = _retTree;
+ }
+ else {
+ break _loop163;
+ }
+
+ } while (true);
+ }
+ }
+ catch (RecognitionException ex) {
+ if (inputState.guessing==0) {
+ reportError(ex);
+ if (_t!=null) {_t = _t.getNextSibling();}
+ } else {
+ throw ex;
+ }
+ }
+ _retTree = _t;
+ }
+
+
+ public static final String[] _tokenNames = {
+ "<0>",
+ "EOF",
+ "<2>",
+ "NULL_TREE_LOOKAHEAD",
+ "\"all\"",
+ "\"any\"",
+ "\"and\"",
+ "\"as\"",
+ "\"asc\"",
+ "\"avg\"",
+ "\"between\"",
+ "\"class\"",
+ "\"count\"",
+ "\"delete\"",
+ "\"desc\"",
+ "DOT",
+ "\"distinct\"",
+ "\"elements\"",
+ "\"escape\"",
+ "\"exists\"",
+ "\"false\"",
+ "\"fetch\"",
+ "\"from\"",
+ "\"full\"",
+ "\"group\"",
+ "\"having\"",
+ "\"in\"",
+ "\"indices\"",
+ "\"inner\"",
+ "\"insert\"",
+ "\"into\"",
+ "\"is\"",
+ "\"join\"",
+ "\"left\"",
+ "\"like\"",
+ "\"max\"",
+ "\"min\"",
+ "\"new\"",
+ "\"not\"",
+ "\"null\"",
+ "\"or\"",
+ "\"order\"",
+ "\"outer\"",
+ "\"properties\"",
+ "\"right\"",
+ "\"select\"",
+ "\"set\"",
+ "\"some\"",
+ "\"sum\"",
+ "\"true\"",
+ "\"union\"",
+ "\"update\"",
+ "\"versioned\"",
+ "\"where\"",
+ "\"case\"",
+ "\"end\"",
+ "\"else\"",
+ "\"then\"",
+ "\"when\"",
+ "\"on\"",
+ "\"with\"",
+ "\"both\"",
+ "\"empty\"",
+ "\"leading\"",
+ "\"member\"",
+ "\"object\"",
+ "\"of\"",
+ "\"trailing\"",
+ "AGGREGATE",
+ "ALIAS",
+ "CONSTRUCTOR",
+ "CASE2",
+ "EXPR_LIST",
+ "FILTER_ENTITY",
+ "IN_LIST",
+ "INDEX_OP",
+ "IS_NOT_NULL",
+ "IS_NULL",
+ "METHOD_CALL",
+ "NOT_BETWEEN",
+ "NOT_IN",
+ "NOT_LIKE",
+ "ORDER_ELEMENT",
+ "QUERY",
+ "RANGE",
+ "ROW_STAR",
+ "SELECT_FROM",
+ "UNARY_MINUS",
+ "UNARY_PLUS",
+ "VECTOR_EXPR",
+ "WEIRD_IDENT",
+ "CONSTANT",
+ "NUM_DOUBLE",
+ "NUM_FLOAT",
+ "NUM_LONG",
+ "JAVA_CONSTANT",
+ "COMMA",
+ "EQ",
+ "OPEN",
+ "CLOSE",
+ "\"by\"",
+ "\"ascending\"",
+ "\"descending\"",
+ "NE",
+ "SQL_NE",
+ "LT",
+ "GT",
+ "LE",
+ "GE",
+ "CONCAT",
+ "PLUS",
+ "MINUS",
+ "STAR",
+ "DIV",
+ "OPEN_BRACKET",
+ "CLOSE_BRACKET",
+ "COLON",
+ "PARAM",
+ "NUM_INT",
+ "QUOTED_STRING",
+ "IDENT",
+ "ID_START_LETTER",
+ "ID_LETTER",
+ "ESCqs",
+ "WS",
+ "HEX_DIGIT",
+ "EXPONENT",
+ "FLOAT_SUFFIX",
+ "FROM_FRAGMENT",
+ "IMPLIED_FROM",
+ "JOIN_FRAGMENT",
+ "SELECT_CLAUSE",
+ "LEFT_OUTER",
+ "RIGHT_OUTER",
+ "ALIAS_REF",
+ "PROPERTY_REF",
+ "SQL_TOKEN",
+ "SELECT_COLUMNS",
+ "SELECT_EXPR",
+ "THETA_JOINS",
+ "FILTERS",
+ "METHOD_NAME",
+ "NAMED_PARAM",
+ "BOGUS",
+ "SQL_NODE"
+ };
+
+ private static final long[] mk_tokenSet_0() {
+ long[] data = { 18612532836077568L, 136163524152934608L, 66880L, 0L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0());
+ private static final long[] mk_tokenSet_1() {
+ long[] data = { 17247503360L, 33543694823424L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1());
+ private static final long[] mk_tokenSet_2() {
+ long[] data = { 1391637038144L, 33543694823424L, 256L, 0L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2());
+ private static final long[] mk_tokenSet_3() {
+ long[] data = { 18753820080246832L, 136163524186491024L, 16704L, 0L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3());
+ private static final long[] mk_tokenSet_4() {
+ long[] data = { 18577898219802624L, 136163524152936592L, 16704L, 0L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4());
+ private static final long[] mk_tokenSet_5() {
+ long[] data = { 18014398509481984L, 1055531171053696L, 0L, 0L};
+ return data;
+ }
+ public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5());
+ }
+
Property changes on: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlGeneratorBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -0,0 +1,154 @@
+// $ANTLR 2.7.2: "sql-gen.g" -> "SqlGeneratorBase.java"$
+
+// $Id: sql-gen.g 15746 2009-01-06 17:14:14Z cbredesen $
+package org.hibernate.hql.antlr;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+public interface SqlTokenTypes {
+ int EOF = 1;
+ int NULL_TREE_LOOKAHEAD = 3;
+ int ALL = 4;
+ int ANY = 5;
+ int AND = 6;
+ int AS = 7;
+ int ASCENDING = 8;
+ int AVG = 9;
+ int BETWEEN = 10;
+ int CLASS = 11;
+ int COUNT = 12;
+ int DELETE = 13;
+ int DESCENDING = 14;
+ int DOT = 15;
+ int DISTINCT = 16;
+ int ELEMENTS = 17;
+ int ESCAPE = 18;
+ int EXISTS = 19;
+ int FALSE = 20;
+ int FETCH = 21;
+ int FROM = 22;
+ int FULL = 23;
+ int GROUP = 24;
+ int HAVING = 25;
+ int IN = 26;
+ int INDICES = 27;
+ int INNER = 28;
+ int INSERT = 29;
+ int INTO = 30;
+ int IS = 31;
+ int JOIN = 32;
+ int LEFT = 33;
+ int LIKE = 34;
+ int MAX = 35;
+ int MIN = 36;
+ int NEW = 37;
+ int NOT = 38;
+ int NULL = 39;
+ int OR = 40;
+ int ORDER = 41;
+ int OUTER = 42;
+ int PROPERTIES = 43;
+ int RIGHT = 44;
+ int SELECT = 45;
+ int SET = 46;
+ int SOME = 47;
+ int SUM = 48;
+ int TRUE = 49;
+ int UNION = 50;
+ int UPDATE = 51;
+ int VERSIONED = 52;
+ int WHERE = 53;
+ int CASE = 54;
+ int END = 55;
+ int ELSE = 56;
+ int THEN = 57;
+ int WHEN = 58;
+ int ON = 59;
+ int WITH = 60;
+ int BOTH = 61;
+ int EMPTY = 62;
+ int LEADING = 63;
+ int MEMBER = 64;
+ int OBJECT = 65;
+ int OF = 66;
+ int TRAILING = 67;
+ int AGGREGATE = 68;
+ int ALIAS = 69;
+ int CONSTRUCTOR = 70;
+ int CASE2 = 71;
+ int EXPR_LIST = 72;
+ int FILTER_ENTITY = 73;
+ int IN_LIST = 74;
+ int INDEX_OP = 75;
+ int IS_NOT_NULL = 76;
+ int IS_NULL = 77;
+ int METHOD_CALL = 78;
+ int NOT_BETWEEN = 79;
+ int NOT_IN = 80;
+ int NOT_LIKE = 81;
+ int ORDER_ELEMENT = 82;
+ int QUERY = 83;
+ int RANGE = 84;
+ int ROW_STAR = 85;
+ int SELECT_FROM = 86;
+ int UNARY_MINUS = 87;
+ int UNARY_PLUS = 88;
+ int VECTOR_EXPR = 89;
+ int WEIRD_IDENT = 90;
+ int CONSTANT = 91;
+ int NUM_DOUBLE = 92;
+ int NUM_FLOAT = 93;
+ int NUM_LONG = 94;
+ int JAVA_CONSTANT = 95;
+ int COMMA = 96;
+ int EQ = 97;
+ int OPEN = 98;
+ int CLOSE = 99;
+ int LITERAL_by = 100;
+ int LITERAL_ascending = 101;
+ int LITERAL_descending = 102;
+ int NE = 103;
+ int SQL_NE = 104;
+ int LT = 105;
+ int GT = 106;
+ int LE = 107;
+ int GE = 108;
+ int CONCAT = 109;
+ int PLUS = 110;
+ int MINUS = 111;
+ int STAR = 112;
+ int DIV = 113;
+ int OPEN_BRACKET = 114;
+ int CLOSE_BRACKET = 115;
+ int COLON = 116;
+ int PARAM = 117;
+ int NUM_INT = 118;
+ int QUOTED_STRING = 119;
+ int IDENT = 120;
+ int ID_START_LETTER = 121;
+ int ID_LETTER = 122;
+ int ESCqs = 123;
+ int WS = 124;
+ int HEX_DIGIT = 125;
+ int EXPONENT = 126;
+ int FLOAT_SUFFIX = 127;
+ int FROM_FRAGMENT = 128;
+ int IMPLIED_FROM = 129;
+ int JOIN_FRAGMENT = 130;
+ int SELECT_CLAUSE = 131;
+ int LEFT_OUTER = 132;
+ int RIGHT_OUTER = 133;
+ int ALIAS_REF = 134;
+ int PROPERTY_REF = 135;
+ int SQL_TOKEN = 136;
+ int SELECT_COLUMNS = 137;
+ int SELECT_EXPR = 138;
+ int THETA_JOINS = 139;
+ int FILTERS = 140;
+ int METHOD_NAME = 141;
+ int NAMED_PARAM = 142;
+ int BOGUS = 143;
+ int SQL_NODE = 144;
+}
Property changes on: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt 2009-08-03 02:58:24 UTC (rev 17224)
@@ -0,0 +1,143 @@
+// $ANTLR 2.7.2: sql-gen.g -> SqlTokenTypes.txt$
+Sql // output token vocab name
+ALL="all"=4
+ANY="any"=5
+AND="and"=6
+AS="as"=7
+ASCENDING="asc"=8
+AVG="avg"=9
+BETWEEN="between"=10
+CLASS="class"=11
+COUNT="count"=12
+DELETE="delete"=13
+DESCENDING="desc"=14
+DOT=15
+DISTINCT="distinct"=16
+ELEMENTS="elements"=17
+ESCAPE="escape"=18
+EXISTS="exists"=19
+FALSE="false"=20
+FETCH="fetch"=21
+FROM="from"=22
+FULL="full"=23
+GROUP="group"=24
+HAVING="having"=25
+IN="in"=26
+INDICES="indices"=27
+INNER="inner"=28
+INSERT="insert"=29
+INTO="into"=30
+IS="is"=31
+JOIN="join"=32
+LEFT="left"=33
+LIKE="like"=34
+MAX="max"=35
+MIN="min"=36
+NEW="new"=37
+NOT="not"=38
+NULL="null"=39
+OR="or"=40
+ORDER="order"=41
+OUTER="outer"=42
+PROPERTIES="properties"=43
+RIGHT="right"=44
+SELECT="select"=45
+SET="set"=46
+SOME="some"=47
+SUM="sum"=48
+TRUE="true"=49
+UNION="union"=50
+UPDATE="update"=51
+VERSIONED="versioned"=52
+WHERE="where"=53
+CASE="case"=54
+END="end"=55
+ELSE="else"=56
+THEN="then"=57
+WHEN="when"=58
+ON="on"=59
+WITH="with"=60
+BOTH="both"=61
+EMPTY="empty"=62
+LEADING="leading"=63
+MEMBER="member"=64
+OBJECT="object"=65
+OF="of"=66
+TRAILING="trailing"=67
+AGGREGATE=68
+ALIAS=69
+CONSTRUCTOR=70
+CASE2=71
+EXPR_LIST=72
+FILTER_ENTITY=73
+IN_LIST=74
+INDEX_OP=75
+IS_NOT_NULL=76
+IS_NULL=77
+METHOD_CALL=78
+NOT_BETWEEN=79
+NOT_IN=80
+NOT_LIKE=81
+ORDER_ELEMENT=82
+QUERY=83
+RANGE=84
+ROW_STAR=85
+SELECT_FROM=86
+UNARY_MINUS=87
+UNARY_PLUS=88
+VECTOR_EXPR=89
+WEIRD_IDENT=90
+CONSTANT=91
+NUM_DOUBLE=92
+NUM_FLOAT=93
+NUM_LONG=94
+JAVA_CONSTANT=95
+COMMA=96
+EQ=97
+OPEN=98
+CLOSE=99
+LITERAL_by="by"=100
+LITERAL_ascending="ascending"=101
+LITERAL_descending="descending"=102
+NE=103
+SQL_NE=104
+LT=105
+GT=106
+LE=107
+GE=108
+CONCAT=109
+PLUS=110
+MINUS=111
+STAR=112
+DIV=113
+OPEN_BRACKET=114
+CLOSE_BRACKET=115
+COLON=116
+PARAM=117
+NUM_INT=118
+QUOTED_STRING=119
+IDENT=120
+ID_START_LETTER=121
+ID_LETTER=122
+ESCqs=123
+WS=124
+HEX_DIGIT=125
+EXPONENT=126
+FLOAT_SUFFIX=127
+FROM_FRAGMENT=128
+IMPLIED_FROM=129
+JOIN_FRAGMENT=130
+SELECT_CLAUSE=131
+LEFT_OUTER=132
+RIGHT_OUTER=133
+ALIAS_REF=134
+PROPERTY_REF=135
+SQL_TOKEN=136
+SELECT_COLUMNS=137
+SELECT_EXPR=138
+THETA_JOINS=139
+FILTERS=140
+METHOD_NAME=141
+NAMED_PARAM=142
+BOGUS=143
+SQL_NODE=144
Property changes on: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/antlr/SqlTokenTypes.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java 2009-08-01 19:58:59 UTC (rev 17223)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/SqlASTFactory.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -1,13 +1,14 @@
// $Id$
package org.hibernate.hql.ast;
-import antlr.ASTFactory;
-import antlr.Token;
-import antlr.collections.AST;
+import java.lang.reflect.Constructor;
+
import org.hibernate.hql.antlr.HqlSqlTokenTypes;
import org.hibernate.hql.ast.tree.AggregateNode;
+import org.hibernate.hql.ast.tree.BetweenOperatorNode;
import org.hibernate.hql.ast.tree.BinaryArithmeticOperatorNode;
import org.hibernate.hql.ast.tree.BinaryLogicOperatorNode;
+import org.hibernate.hql.ast.tree.BooleanLiteralNode;
import org.hibernate.hql.ast.tree.Case2Node;
import org.hibernate.hql.ast.tree.CaseNode;
import org.hibernate.hql.ast.tree.CollectionFunction;
@@ -19,10 +20,14 @@
import org.hibernate.hql.ast.tree.FromElement;
import org.hibernate.hql.ast.tree.IdentNode;
import org.hibernate.hql.ast.tree.ImpliedFromElement;
+import org.hibernate.hql.ast.tree.InLogicOperatorNode;
import org.hibernate.hql.ast.tree.IndexNode;
import org.hibernate.hql.ast.tree.InitializeableNode;
import org.hibernate.hql.ast.tree.InsertStatement;
import org.hibernate.hql.ast.tree.IntoClause;
+import org.hibernate.hql.ast.tree.IsNotNullLogicOperatorNode;
+import org.hibernate.hql.ast.tree.IsNullLogicOperatorNode;
+import org.hibernate.hql.ast.tree.JavaConstantNode;
import org.hibernate.hql.ast.tree.LiteralNode;
import org.hibernate.hql.ast.tree.MethodNode;
import org.hibernate.hql.ast.tree.OrderByClause;
@@ -30,18 +35,16 @@
import org.hibernate.hql.ast.tree.QueryNode;
import org.hibernate.hql.ast.tree.SelectClause;
import org.hibernate.hql.ast.tree.SelectExpressionImpl;
+import org.hibernate.hql.ast.tree.SessionFactoryAwareNode;
import org.hibernate.hql.ast.tree.SqlFragment;
import org.hibernate.hql.ast.tree.SqlNode;
import org.hibernate.hql.ast.tree.UnaryArithmeticNode;
+import org.hibernate.hql.ast.tree.UnaryLogicOperatorNode;
import org.hibernate.hql.ast.tree.UpdateStatement;
-import org.hibernate.hql.ast.tree.BetweenOperatorNode;
-import org.hibernate.hql.ast.tree.UnaryLogicOperatorNode;
-import org.hibernate.hql.ast.tree.InLogicOperatorNode;
-import org.hibernate.hql.ast.tree.JavaConstantNode;
-import org.hibernate.hql.ast.tree.SessionFactoryAwareNode;
-import org.hibernate.hql.ast.tree.BooleanLiteralNode;
-import java.lang.reflect.Constructor;
+import antlr.ASTFactory;
+import antlr.Token;
+import antlr.collections.AST;
/**
* Custom AST factory the intermediate tree that causes ANTLR to create specialized
@@ -157,7 +160,9 @@
case NOT_BETWEEN:
return BetweenOperatorNode.class;
case IS_NULL:
+ return IsNullLogicOperatorNode.class;
case IS_NOT_NULL:
+ return IsNotNullLogicOperatorNode.class;
case EXISTS:
return UnaryLogicOperatorNode.class;
default:
Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.hql.ast.tree;
+
+import antlr.collections.AST;
+
+import org.hibernate.type.Type;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.hql.antlr.HqlSqlTokenTypes;
+import org.hibernate.util.StringHelper;
+import org.hibernate.HibernateException;
+
+/**
+ * AbstractNullnessCheckNode implementation
+ *
+ * @author Steve Ebersole
+ */
+public abstract class AbstractNullnessCheckNode extends UnaryLogicOperatorNode {
+ public void initialize() {
+ // TODO : this really needs to be delayed unitl after we definitively know the operand node type;
+ // where this is currently a problem is parameters for which where we cannot unequivocally
+ // resolve an expected type
+ Type operandType = extractDataType( getOperand() );
+ if ( operandType == null ) {
+ return;
+ }
+ SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory();
+ int operandColumnSpan = operandType.getColumnSpan( sessionFactory );
+ if ( operandColumnSpan > 1 ) {
+ mutateRowValueConstructorSyntax( operandColumnSpan );
+ }
+ }
+
+ protected abstract int getExpansionConnectorType();
+ protected abstract String getExpansionConnectorText();
+
+ private void mutateRowValueConstructorSyntax(int operandColumnSpan) {
+ final int comparisonType = getType();
+ final String comparisonText = getText();
+
+ final int expansionConnectorType = getExpansionConnectorType();
+ final String expansionConnectorText = getExpansionConnectorText();
+
+ setType( expansionConnectorType );
+ setText( expansionConnectorText );
+
+ String[] mutationTexts = extractMutationTexts( getOperand(), operandColumnSpan );
+
+ AST container = this;
+ for ( int i = operandColumnSpan - 1; i > 0; i-- ) {
+ if ( i == 1 ) {
+ AST op1 = getASTFactory().create( comparisonType, comparisonText );
+ AST operand1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[0] );
+ op1.setFirstChild( operand1 );
+ container.setFirstChild( op1 );
+ AST op2 = getASTFactory().create( comparisonType, comparisonText );
+ AST operand2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[1] );
+ op2.setFirstChild( operand2 );
+ op1.setNextSibling( op2 );
+ }
+ else {
+ AST op = getASTFactory().create( comparisonType, comparisonText );
+ AST operand = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[i] );
+ op.setFirstChild( operand );
+ AST newContainer = getASTFactory().create( expansionConnectorType, expansionConnectorText );
+ container.setFirstChild( newContainer );
+ newContainer.setNextSibling( op );
+ container = newContainer;
+ }
+ }
+ }
+
+ protected Type extractDataType(Node operand) {
+ Type type = null;
+ if ( operand instanceof SqlNode ) {
+ type = ( ( SqlNode ) operand ).getDataType();
+ }
+ if ( type == null && operand instanceof ExpectedTypeAwareNode ) {
+ type = ( ( ExpectedTypeAwareNode ) operand ).getExpectedType();
+ }
+ return type;
+ }
+
+ private static String[] extractMutationTexts(Node operand, int count) {
+ if ( operand instanceof ParameterNode ) {
+ String[] rtn = new String[count];
+ for ( int i = 0; i < count; i++ ) {
+ rtn[i] = "?";
+ }
+ return rtn;
+ }
+ else if ( operand.getType() == HqlSqlTokenTypes.VECTOR_EXPR ) {
+ String[] rtn = new String[ operand.getNumberOfChildren() ];
+ int x = 0;
+ AST node = operand.getFirstChild();
+ while ( node != null ) {
+ rtn[ x++ ] = node.getText();
+ node = node.getNextSibling();
+ }
+ return rtn;
+ }
+ else if ( operand instanceof SqlNode ) {
+ String nodeText = operand.getText();
+ if ( nodeText.startsWith( "(" ) ) {
+ nodeText = nodeText.substring( 1 );
+ }
+ if ( nodeText.endsWith( ")" ) ) {
+ nodeText = nodeText.substring( 0, nodeText.length() - 1 );
+ }
+ String[] splits = StringHelper.split( ", ", nodeText );
+ if ( count != splits.length ) {
+ throw new HibernateException( "SqlNode's text did not reference expected number of columns" );
+ }
+ return splits;
+ }
+ else {
+ throw new HibernateException( "dont know how to extract row value elements from node : " + operand );
+ }
+ }
+}
Property changes on: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/AbstractNullnessCheckNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.hql.ast.tree;
+
+import org.hibernate.hql.antlr.HqlSqlTokenTypes;
+
+/**
+ * IsNotNullLogicOperatorNode implementation
+ *
+ * @author Steve Ebersole
+ */
+public class IsNotNullLogicOperatorNode extends AbstractNullnessCheckNode {
+ protected int getExpansionConnectorType() {
+ return HqlSqlTokenTypes.OR;
+ }
+
+ protected String getExpansionConnectorText() {
+ return "OR";
+ }
+}
Property changes on: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNotNullLogicOperatorNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java (rev 0)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2007, Red Hat Middleware, LLC. All rights reserved.
+ *
+ * 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, v. 2.1. This program is distributed in the
+ * hope that it will be useful, but WITHOUT A 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, v.2.1 along with this
+ * distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Red Hat Author(s): Steve Ebersole
+ */
+package org.hibernate.hql.ast.tree;
+
+import org.hibernate.hql.antlr.HqlSqlTokenTypes;
+
+/**
+ * Represents a 'is null' check.
+ *
+ * @author Steve Ebersole
+ */
+public class IsNullLogicOperatorNode extends AbstractNullnessCheckNode {
+ protected int getExpansionConnectorType() {
+ return HqlSqlTokenTypes.AND;
+ }
+
+ protected String getExpansionConnectorText() {
+ return "AND";
+ }
+}
Property changes on: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/IsNullLogicOperatorNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/UnaryLogicOperatorNode.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/UnaryLogicOperatorNode.java 2009-08-01 19:58:59 UTC (rev 17223)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/tree/UnaryLogicOperatorNode.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -4,9 +4,11 @@
import org.hibernate.Hibernate;
/**
- * @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
+ * Represents a unary operator node.
+ *
+ * @author Steve Ebersole
*/
-public class UnaryLogicOperatorNode extends SqlNode implements UnaryOperatorNode {
+public class UnaryLogicOperatorNode extends HqlSqlWalkerNode implements UnaryOperatorNode {
public Node getOperand() {
return ( Node ) getFirstChild();
}
Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-08-01 19:58:59 UTC (rev 17223)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2009-08-03 02:58:24 UTC (rev 17224)
@@ -104,6 +104,41 @@
return new FunctionalTestClassTestSuite( ASTParserLoadingTest.class );
}
+ public void testComponentNullnessChecks() {
+ Session s = openSession();
+ s.beginTransaction();
+ Human h = new Human();
+ h.setName( new Name( "Johnny", 'B', "Goode" ) );
+ s.save( h );
+ h = new Human();
+ h.setName( new Name( "Steve", null, "Ebersole" ) );
+ s.save( h );
+ h = new Human();
+ h.setName( new Name( "Bono", null, null ) );
+ s.save( h );
+ h = new Human();
+ h.setName( new Name( null, null, null ) );
+ s.save( h );
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ List results = s.createQuery( "from Human where name is null" ).list();
+ assertEquals( 1, results.size() );
+ results = s.createQuery( "from Human where name is not null" ).list();
+ assertEquals( 3, results.size() );
+ s.createQuery( "from Human where ? is null" ).setParameter( 0, null ).list();
+ s.getTransaction().commit();
+ s.close();
+
+ s = openSession();
+ s.beginTransaction();
+ s.createQuery( "delete Human" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testInvalidCollectionDereferencesFail() {
Session s = openSession();
s.beginTransaction();
14 years, 9 months