-->
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.  [ 8 posts ] 
Author Message
 Post subject: could not resolve property
PostPosted: Mon May 15, 2006 3:06 pm 
Newbie

Joined: Tue May 02, 2006 1:59 pm
Posts: 17
Location: California
Hibernate Version 3.1

I am getting exception(could not resolve property) when I do the following query :

Query q1 = newSession.createQuery("from VsDomains domains where domains.dns_profile_id = :dns_profile")

But everything is fine when I do the one below :
Query q1 = newSession.createQuery("from VsDomains where dns_profile_id = :dns_profile_id");

This is the code that invokes the query:
.setProperty("hibernate.query.factory_class","org.hibernate.hql.classic.ClassicQueryTranslatorFactory")
.setProperty("hibernate.dialect", "org.hibernate.dialect.Oracle9Dialect")
.setProperty("hibernate.connection.driver_class", "oracle.jdbc.driver.OracleDriver")
test.factory = cfg.buildSessionFactory();
Session newSession = test.factory.openSession();
Transaction newTransaction = newSession.beginTransaction();

Query q1 = newSession.createQuery("from VsDomains domains where domains.dns_profile_id = :dns_profile_id");
q1.setParameter("dns_profile_id",f_dnsProfileId);



Exception :
---------------------------------

DEBUG 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <hql.ast.QueryTranslatorImpl> parse() - HQL: from com.verisign.dbms.portal.VsDomains d where d.dns_profile_id = :dns_profile_id
DEBUG 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <hql.ast.AST> --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| \-[FROM] 'from'
| | \-[IDENT] 'VsDomains'
| \-[ALIAS] 'd'
\-[WHERE] 'where'
\-[EQ] '='
+-[DOT] '.'
| +-[IDENT] 'd'
| \-[IDENT] 'dns_profile_id'
\-[COLON] ':'
\-[IDENT] 'dns_profile_id'

DEBUG 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <hql.ast.ErrorCounter> throwQueryException() : no errors
DEBUG 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <hql.antlr.HqlSqlBaseWalker> select << begin [level=1, statement=select]
DEBUG 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <ast.tree.FromElement> FromClause{level=1} : VsDomains (d) -> vsdomains0_
DEBUG 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <ast.tree.FromReferenceNode> Resolved : d -> vsdomains0_.ASSET_ID
INFO 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <com.verisign.dbms> <kshobhana-lnx.corpc.vrsn.com><DBMS><><DBMS-DBMS><><><EditAdminDNSProfileAction: Exception during Modify @loc#1org.hibernate.QueryException: could not resolve property: dns_profile_id of: VsDomains [from VsDomains d where d.dns_profile_id = :dns_profile_id]>
ERROR 05/16/2006 12:42:36 <ExecuteThread: '59' for queue: 'default'> <dbms.common.DBMAction> <kshobhana-lnx.corpc.vrsn.com><DBMS><><execute><><DBMChainedException: could not resolve property: dns_profile_id of: VsDomains [from VsDomains d where d.dns_profile_id = :dns_profile_id]; nested exception is: org.hibernate.QueryException: could not resolve property: dns_profile_id of: VsDomains [from VsDomains d where d.dns_profile_id = :dns_profile_id]org.hibernate.QueryException: could not resolve property: dns_profile_id of: VsDomains [from VsDomains d where d.dns_profile_id = :dns_profile_id]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(Ljava.lang.String;)V(AbstractPropertyMapping.java:43) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(Ljava.lang.String;)Lorg.hibernate.type.Type;(AbstractPropertyMapping.java:37) at org.hibernate.persister.entity.AbstractEntityPersister.toType(Ljava.lang.String;)Lorg.hibernate.type.Type;(AbstractEntityPersister.java:1265) at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(Ljava.lang.String;Ljava.lang.String;)Lorg.hibernate.type.Type;(FromElementType.java:279) at org.hibernate.hql.ast.tree.FromElement.getPropertyType(Ljava.lang.String;Ljava.lang.String;)Lorg.hibernate.type.Type;(FromElement.java:372)
at org.hibernate.hql.ast.tree.DotNode.getDataType()Lorg.hibernate.type.Type;(DotNode.java:539)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs()Lorg.hibernate.type.Type;(DotNode.java:221)
at org.hibernate.hql.ast.tree.DotNode.resolve(ZZLjava.lang.String;Lantlr.collections.AST;)V(DotNode.java:172)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(ZZLjava.lang.String;)V(FromReferenceNode.java:94)
at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(ZZ)V(FromReferenceNode.java:90)
at org.hibernate.hql.ast.HqlSqlWalker.resolve(Lantlr.collections.AST;)V(HqlSqlWalker.java:725)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:1215)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:4032)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:3518)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:1758)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(Lantlr.collections.AST;)V(HqlSqlBaseWalker.java:229) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(Lorg.hibernate.hql.ast.HqlParser;Ljava.lang.String;)Lorg.hibernate.hql.ast.HqlSqlWalker;(QueryTranslatorImpl.java:218)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(Ljava.util.Map;ZLjava.lang.String;)V(QueryTranslatorImpl.java:158) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(Ljava.util.Map;Z)V(QueryTranslatorImpl.java:109) at org.hibernate.engine.query.HQLQueryPlan.<init>(Ljava.lang.String;Ljava.lang.String;ZLjava.util.Map;Lorg.hibernate.engine.SessionFactoryImplementor;)V(HQLQueryPlan.java:75) at org.hibernate.engine.query.HQLQueryPlan.<init>(Ljava.lang.String;ZLjava.util.Map;Lorg.hibernate.engine.SessionFactoryImplementor;)V(HQLQueryPlan.java:54) at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(Ljava.lang.String;ZLjava.util.Map;)Lorg.hibernate.engine.query.HQLQueryPlan;(QueryPlanCache.java:71) at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(Ljava.lang.String;Z)Lorg.hibernate.engine.query.HQLQueryPlan;(AbstractSessionImpl.java:133) at org.hibernate.impl.AbstractSessionImpl.createQuery(Ljava.lang.String;)Lorg.hibernate.Query;(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(Ljava.lang.String;)Lorg.hibernate.Query;(SessionImpl.java:1583)

I have been struggling on this for a while and have not found a wokring answer yet.

Thanks
S

_________________
Thanks


Last edited by shobhanakirtane on Tue May 16, 2006 3:53 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Could some one please let me know what the error is ?
PostPosted: Tue May 16, 2006 11:23 am 
Newbie

Joined: Tue May 02, 2006 1:59 pm
Posts: 17
Location: California
Anybody has solved this kind of an error ???

Thanks
S

_________________
Thanks


Top
 Profile  
 
 Post subject: All the Hibernate experts
PostPosted: Tue May 16, 2006 2:22 pm 
Newbie

Joined: Tue May 02, 2006 1:59 pm
Posts: 17
Location: California
All the Hibernate experts .. please look into this problem !!

_________________
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 2:35 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
If you could provide more information like mapping files, sometimes even novice's can be helpful to you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 3:16 pm 
Newbie

Joined: Tue May 02, 2006 1:59 pm
Posts: 17
Location: California
Mapping file for the VsDomains table/class

--------------------------------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated May 12, 2006 11:21:53 AM by Hibernate Tools 3.1.0 beta3 -->
<hibernate-mapping>
<class name="VsDomains" table="VS_DOMAINS">
<id name="assetId" type="java.lang.Long">
<column name="ASSET_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="vsMdnsAccountT" class="VsMdnsAccountT" fetch="select">
<column name="MDNS_ACCOUNT_NAME" length="100" />
</many-to-one>
<many-to-one name="vsRegistrationProfileT" class="VsRegistrationProfileT" fetch="select">
<column name="REG_PROFILE_ID" precision="22" scale="0" />
</many-to-one>
<property name="domain" type="string">
<column name="DOMAIN" length="64" not-null="true" />
</property>
<property name="subDomain" type="string">
<column name="SUB_DOMAIN" length="10" />
</property>
<property name="dnsProfileId" type="java.lang.Long">
<column name="DNS_PROFILE_ID" precision="22" scale="0" not-null="false" />
</property>
</class>
</hibernate-mapping>
----------------------------------------------------------------------------

The Java Bean for the same class VsDomains.java :
import java.lang.Long;


/**
* VsDomains generated by hbm2java
*/

public class VsDomains implements java.io.Serializable {


// Fields

private Long assetId;
private VsMdnsAccountT vsMdnsAccountT;
private VsRegistrationProfileT vsRegistrationProfileT;
private String domain;
private String subDomain;
private Long dnsProfileId;
.............................................................
.
.
.
public Long getDnsProfileId() {
return this.dnsProfileId;
}

public void setDnsProfileId(Long dnsProfileId) {
this.dnsProfileId = dnsProfileId;
}


Anybody's help will be appreciated.

Thanks
Shobhana

_________________
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 3:37 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
your query should be

from VsDomains domains where domains.dnsProfileId = :dns_profile_id

Also you have been version 3.x of hibernate. However error trace points to classic version of hibernate( 2.x ). Check to see if you have correct jar files in your classpath.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 4:09 pm 
Newbie

Joined: Tue May 02, 2006 1:59 pm
Posts: 17
Location: California
Thanks bkmr_77 !!

Thats helped, but one question why do we use dnsProfileId for alias query and dns_profile_id when there is no alias ?
That is

Query q1 = newSession.createQuery("from VsDomains domains where domains.dnsProfileId = :dns_profile")

Query q1 = newSession.createQuery("from VsDomains where dns_profile_id = :dns_profile_id");

Both queries work great .

Yeah I just updated my weblogic domain to use the latest antlr .. so now I am not using the classic parser !!

Thanks a ton,
S

_________________
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 16, 2006 10:15 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
It seems like HQLParser is using the VsDomains model information to resolve if dns_profile_id is defined in the property mappings. So the second form of the query is also working.

Try giving any other property that is existing in the table but not defined in the hibernate mapping file. It should not work because the column cannot be resolved to any defined property.


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