-->
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.  [ 3 posts ] 
Author Message
 Post subject: QueryException: not an entity
PostPosted: Sat Aug 19, 2006 5:14 pm 
Newbie

Joined: Sun Jun 04, 2006 8:46 am
Posts: 13
This query

Code:
select u.properties from User u


with this mapping

Code:
    /**
     * @hibernate.map table="userprops" lazy="true" cascade="all"
     * @hibernate.collection-key column="userid"
     * @hibernate.collection-index column="mapkey" type="string"
     * @hibernate.collection-element column="value" type="string"
     */
   public Map getProperties() {
      return properties;
   }


produces this error


Code:
org.hibernate.QueryException: not an entity [select u.properties from User u]
   at org.hibernate.hql.ast.tree.FromElementType.renderIdentifierSelect(FromElementType.java:143)
   at org.hibernate.hql.ast.tree.FromElement.renderIdentifierSelect(FromElement.java:167)
   at org.hibernate.hql.ast.tree.SelectClause.renderNonScalarIdentifiers(SelectClause.java:398)
   at org.hibernate.hql.ast.tree.SelectClause.renderNonScalarSelects(SelectClause.java:376)
   at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:218)
   at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:702)
   at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:531)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:645)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)


How can I fix it?
Thx

_________________
--- cogens


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 20, 2006 8:09 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Either select the user, or select a collection of scalars. You cannot select a map like that.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 5:46 pm 
Newbie

Joined: Sun Jun 04, 2006 8:46 am
Posts: 13
Thank you for your reply.

That's what I thought, but from the documentation I could not tell if I was right.

What I've learned so far is that no collection can be selected this way, whereas an entity can (e.g. in case of many2one), besides value types, which was kind of an unexpected behaviour for me.

_________________
--- cogens


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.