Hi,
can anybody help with the following error:
Hibernate version: 3.0 / 3.1rc2
Java-classes:
Code:
Class Data {
int id;
Map scaledImages; // contains objects of type ScaledImage
}
Class MasterImage {
int id;
}
class ScaledImage {
MasterImage img;
String scaling;
}
Mapping XML file:
Code:
<class name = "Data" table = "data">
<id name = "id">
<generator class = "native"/>
</id>
<map name = "scaledImages" table = "image" >
<key column = "object_id"/>
<index column = "name" type = "string"/>
<composite-element class="ScaledImage">
<many-to-one name = "masterImage"
class = "MasterImage"
column = "masterimage_id"/>
<property name = "scaling" column = "scaling"/>
</composite-element>
</map>
</class>
<class name = "MasterImage" table = "img">
<id name = "id">
<generator class = "native"/>
</id>
<property name = "name" />
</class>
HQL:
Code:
"from Data X where X.scaledImages.masterImage.id=1"
QueryException: illegal syntax near collection: masterImageCriteriaAPI:
Code:
createAlias("scaledImages","img")
causes a
MappingException: "collection was not an association: Data.scaledImages"What I want is a query in HQL or Criteria API that returns a list of all Data-Objects, where their Map of ScaledImages images includes a specific ScaledImage based on a MasterImage.
As far as I can remember, the HQL
Code:
"from Data X where X.scaledImages.masterImage.id=1"
used to work with Hibernate < 3.0.
regards Axel