Author: steve.ebersole(a)jboss.com
Date: 2006-12-05 14:43:04 -0500 (Tue, 05 Dec 2006)
New Revision: 10932
Added:
trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java
Modified:
trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
Log:
HHH-2284 : HQL + sub-component references
Modified: trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java 2006-12-05 19:42:41 UTC
(rev 10931)
+++ trunk/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java 2006-12-05 19:43:04 UTC
(rev 10932)
@@ -521,10 +521,9 @@
}
}
else {
- // Handle "select foo.component from Foo foo", or even "where
foo.component = bar.component"
- AST lhs = getFirstChild();
- AST rhs = lhs.getNextSibling();
- propertyPath = rhs.getText();
+ if ( log.isDebugEnabled() ) {
+ log.debug( "terminal propertyPath = [" + propertyPath + "]" );
+ }
}
}
Added: trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml 2006-12-05
19:42:41 UTC (rev 10931)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml 2006-12-05
19:43:04 UTC (rev 10932)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping SYSTEM
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
+
+<hibernate-mapping package="org.hibernate.test.hql"
default-access="field">
+
+ <class name="ComponentContainer" table="HQL_COMP_CONT">
+ <id name="id" type="long" column="ID">
+ <generator class="increment" />
+ </id>
+ <component name="address"
class="ComponentContainer$Address">
+ <property name="street" type="string"
column="STREET_ADDR" />
+ <property name="city" type="string"
column="CITY_ADDR" />
+ <property name="state" type="string"
column="STATE_ADDR" />
+ <component name="zip"
class="ComponentContainer$Address$Zip">
+ <property name="code" type="int"
column="ZIP_CODE_ADDR" />
+ <property name="plus4" type="int"
column="ZIP_PLUS4_ADDR" />
+ </component>
+ </component>
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java 2006-12-05
19:42:41 UTC (rev 10931)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java 2006-12-05
19:43:04 UTC (rev 10932)
@@ -0,0 +1,107 @@
+package org.hibernate.test.hql;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Steve Ebersole
+ */
+public class ComponentContainer {
+
+ private Long id;
+ private ComponentContainer.Address address;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public ComponentContainer.Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(ComponentContainer.Address address) {
+ this.address = address;
+ }
+
+ public static class Address {
+ private String street;
+ private String city;
+ private String state;
+ private ComponentContainer.Address.Zip zip;
+
+ public Address() {
+ }
+
+ public Address(String street, String city, String state, ComponentContainer.Address.Zip
zip) {
+ this.street = street;
+ this.city = city;
+ this.state = state;
+ this.zip = zip;
+ }
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ public ComponentContainer.Address.Zip getZip() {
+ return zip;
+ }
+
+ public void setZip(ComponentContainer.Address.Zip zip) {
+ this.zip = zip;
+ }
+
+ public static class Zip {
+ private int code;
+ private int plus4;
+
+ public Zip() {
+ }
+
+ public Zip(int code, int plus4) {
+ this.code = code;
+ this.plus4 = plus4;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public void setCode(int code) {
+ this.code = code;
+ }
+
+ public int getPlus4() {
+ return plus4;
+ }
+
+ public void setPlus4(int plus4) {
+ this.plus4 = plus4;
+ }
+ }
+ }
+
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2006-12-05 19:42:41 UTC (rev
10931)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/HQLTest.java 2006-12-05 19:43:04 UTC (rev
10932)
@@ -52,6 +52,12 @@
//FAILING TESTS:
+ public void testSubComponentReferences() {
+ assertTranslation( "select c.address.zip.code from ComponentContainer c" );
+ assertTranslation( "select c.address.zip from ComponentContainer c" );
+ assertTranslation( "select c.address from ComponentContainer c" );
+ }
+
public void testManyToAnyReferences() {
assertTranslation( "from PropertySet p where p.someSpecificProperty.id is not
null" );
assertTranslation( "from PropertySet p join p.generalProperties gp where gp.id is
not null" );
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2006-12-05
19:42:41 UTC (rev 10931)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java 2006-12-05
19:43:04 UTC (rev 10932)
@@ -500,6 +500,7 @@
"hql/EntityWithCrazyCompositeKey.hbm.xml",
"hql/CrazyIdFieldNames.hbm.xml",
"hql/SimpleEntityWithAssociation.hbm.xml",
+ "hql/ComponentContainer.hbm.xml",
"batchfetch/ProductLine.hbm.xml",
"cid/Customer.hbm.xml",
"cid/Order.hbm.xml",
Show replies by date