[hibernate-commits] Hibernate SVN: r10931 - in branches/Branch_3_2/Hibernate3: src/org/hibernate/hql/ast/tree test/org/hibernate/test/hql

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Dec 5 14:42:43 EST 2006


Author: steve.ebersole at jboss.com
Date: 2006-12-05 14:42:41 -0500 (Tue, 05 Dec 2006)
New Revision: 10931

Added:
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java
Modified:
   branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
Log:
HHH-2284 : HQL + sub-component references

Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java	2006-12-05 19:05:47 UTC (rev 10930)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/hql/ast/tree/DotNode.java	2006-12-05 19:42:41 UTC (rev 10931)
@@ -5,7 +5,6 @@
 import org.hibernate.engine.JoinSequence;
 import org.hibernate.hql.CollectionProperties;
 import org.hibernate.hql.antlr.SqlTokenTypes;
-import org.hibernate.hql.antlr.HqlSqlTokenTypes;
 import org.hibernate.hql.ast.util.ASTPrinter;
 import org.hibernate.hql.ast.util.ASTUtil;
 import org.hibernate.hql.ast.util.ColumnHelper;
@@ -522,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: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml	2006-12-05 19:05:47 UTC (rev 10930)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.hbm.xml	2006-12-05 19:42:41 UTC (rev 10931)
@@ -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: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java	2006-12-05 19:05:47 UTC (rev 10930)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/ComponentContainer.java	2006-12-05 19:42:41 UTC (rev 10931)
@@ -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: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java	2006-12-05 19:05:47 UTC (rev 10930)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/HQLTest.java	2006-12-05 19:42:41 UTC (rev 10931)
@@ -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: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java	2006-12-05 19:05:47 UTC (rev 10930)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/hql/QueryTranslatorTestCase.java	2006-12-05 19:42:41 UTC (rev 10931)
@@ -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",




More information about the hibernate-commits mailing list