-->
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: org.hibernate.QueryException: could not resolve property
PostPosted: Tue May 22, 2007 5:44 am 
Newbie

Joined: Tue May 22, 2007 5:32 am
Posts: 2
How can I filter data on email property?
Hibernate version: 3

Mapping documents:
<class name="package.User" table="user">
<id name="id" column="id" type="long">
<generator class="sequence">
<param name="sequence">SEQ</param>
</generator>
</id>

<property name="login" type="string" column="login" />

<join table="info">
<key column="user_id" />
<property name="info" type="package.InfoUserType">
<column name="email" />
</property>
</join>
</class>

Code between sessionFactory.openSession() and session.close():
String HQL = "from package.User user where user.info.email like :email";
Query query = getSession().createQuery(HQL);
List<Site> results = query.list();

Full stack trace of any exception that occurs:
org.hibernate.QueryException: could not resolve property: email of: package.User [from package.User user where user.info.email like :email]
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:38)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1354)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:553)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:227)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:178)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:728)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1216)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3669)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
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:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
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:1623)

Name and version of the database you are using:
Oracle 9i
The generated SQL (show_sql=true):
NA
Debug level Hibernate log excerpt:

Problems with Session and transaction handling?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 5:53 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
you should add the join table to from in hql.
like :
from a inner join b where...

in your case, email field cannot be found, since the info class is not added.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 6:19 am 
Newbie

Joined: Tue May 22, 2007 5:32 am
Posts: 2
Thanks for the help.

I have a class User something like this

class User {
private Info info;

public Info getInfo(){
return this.info;
}

public void setInfo(Info info) {
this.info = info;
}
}

and in the same way Info has email property, why that property is not visible?
we should be able to filter on email, because hibernate is already qurieing the info table in DB.


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.