diff --git a/documentation/src/main/docbook/manual/en-US/content/query_criteria.xml b/documentation/src/main/docbook/manual/en-US/content/query_criteria.xml
index 51cdc10353..466a14da11 100644
--- a/documentation/src/main/docbook/manual/en-US/content/query_criteria.xml
+++ b/documentation/src/main/docbook/manual/en-US/content/query_criteria.xml
@@ -250,7 +250,26 @@ while ( iter.hasNext() ) {
-
+
+
+ Components
+
+
+ To add a restriction against a property of an embedded component, the component property
+ name should be prepended to the property name when creating the Restriction.
+ The criteria object should be created on the owning entity, and cannot be created on the component
+ itself. For example, suppose the Cat has a component property fullName
+ with sub-properties firstName and lastName:
+
+
+
+
+
+
+
Example queries
diff --git a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
index 4e784f0196..abae77f85b 100755
--- a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
+++ b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java
@@ -269,7 +269,11 @@ public class CriteriaQueryTranslator implements CriteriaQuery {
componentPath = "";
}
else if ( type.isComponentType() ) {
- componentPath += '.';
+ if (!tokens.hasMoreTokens()) {
+ throw new QueryException("Criteria objects cannot be created directly on components. Create a criteria on owning entity and use a dotted property to access component property: "+path);
+ } else {
+ componentPath += '.';
+ }
}
else {
throw new QueryException( "not an association: " + componentPath );