-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Exception with composite-element using HQL or Criteria API
PostPosted: Sun Nov 06, 2005 9:51 pm 
Newbie

Joined: Sat Feb 26, 2005 2:33 pm
Posts: 4
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: masterImage


CriteriaAPI:
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.