-->
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.  [ 2 posts ] 
Author Message
 Post subject: query: expecting 'elements' or 'indices' after: id
PostPosted: Tue Aug 31, 2004 7:52 am 
Newbie

Joined: Tue Aug 24, 2004 8:41 am
Posts: 15
Location: Amersfoort, the Netherlands
Hibernate version: 2.1

I'm trying to execute the following piece of code (using springframework)

Code:
public List getProductTree() {
        try {
            List l = getHibernateTemplate().createQuery(getSession(),   
                "select new nl.xiam.infomas.sx.ps.TreeNode(pg.titles) "+
                "from nl.xiam.infomas.sx.model.ProductGroup pg").list();
            return l;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }


And I get the following hibernate query exception:

Code:
net.sf.hibernate.QueryException:
expecting 'elements' or 'indices' after:
  id [select new nl.xiam.infomas.sx.ps.TreeNode(pg.titles) from
  nl.xiam.infomas.sx.model.ProductGroup pg]
at net.sf.hibernate.collection.CollectionPropertyMapping.toType(CollectionPropertyMapping.java:53)...etc...


basically its
Code:
select new Bar(f.prop) from Foo f
. The titles is a map instance. Foo is mapped, bar is not. For all the examples I've seen this should work.

I tried a couple of alternatives, but each time I try to use 'new' it just doesn't want to do it. I know I must not be understanding the syntax right.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 31, 2004 9:50 am 
Regular
Regular

Joined: Wed Aug 18, 2004 5:16 am
Posts: 69
Location: Modena, Italy
You can eliminate the error in this way:
Code:
select new nl.xiam.infomas.sx.ps.TreeNode(elements(pg.titles)) from nl.xiam.infomas.sx.model.ProductGroup pg

But you will get another error because it is impossible use collections in projection.

I have tried a similar thing but Hibernate when look for the right constructor of TreeNode search the constructor with Title (if your map is a map of class Title), not with Map or other collections.


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

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.