-->
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.  [ 5 posts ] 
Author Message
 Post subject: HQL problem
PostPosted: Wed Mar 08, 2006 7:46 am 
Newbie

Joined: Wed Mar 08, 2006 7:12 am
Posts: 3
Hello! I'm a beginner in Hibernate and I get the following error:

org.hibernate.QueryException: could not resolve property: parentId of: eurolegis.AboutEutree [from eurolegis.AboutEutree o where o.parentId = 0]

What can be the problem?


Top
 Profile  
 
 Post subject: Re: HQL problem
PostPosted: Wed Mar 08, 2006 8:34 am 
Regular
Regular

Joined: Tue Mar 07, 2006 11:18 am
Posts: 54
Location: Berlin
A bit more information would convince some other to give you a hand.... :)

Post your mapping, the code, stacktrace, version of hibernate etc.

read this:
http://www.hibernate.org/ForumMailinglists/HowToAskForHelp

I guess AboutEutree has no property mapped to "parentId".........

simon

bm2004mvc wrote:
Hello! I'm a beginner in Hibernate and I get the following error:

org.hibernate.QueryException: could not resolve property: parentId of: eurolegis.AboutEutree [from eurolegis.AboutEutree o where o.parentId = 0]

What can be the problem?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 8:53 am 
Newbie

Joined: Wed Mar 08, 2006 7:12 am
Posts: 3
Sorry for giving so few details :)

The files have been generated with Hibernate Tools for Eclipse.
The database is PostgreSQL and the table in this case has the structure:
CREATE TABLE eurolegis."AboutEUTree"
(
"TextRo" numeric,
"ParentId" numeric,
"TitleRo" text,
"TitleEn" text,
nivel int2
)
------------------------------------------------------------------
The files are:

1. AboutEutree.java

public class AboutEutree implements java.io.Serializable {


// Fields

private AboutEutreeId id;


// Constructors

/** default constructor */
public AboutEutree() {
}


/** full constructor */
public AboutEutree(AboutEutreeId id) {
this.id = id;
}

// Property accessors

public AboutEutreeId getId() {
return this.id;
}

public void setId(AboutEutreeId id) {
this.id = id;
}
}

------------------------------------------------------------------
2. AboutEutreeId.java

import java.math.BigDecimal;


/**
* AboutEutreeId generated by hbm2java
*/

public class AboutEutreeId implements java.io.Serializable {


// Fields

private BigDecimal textRo;
private BigDecimal parentId;
private String titleRo;
private String titleEn;


// Constructors

/** default constructor */
public AboutEutreeId() {
}


/** full constructor */
public AboutEutreeId(BigDecimal textRo, BigDecimal parentId, String titleRo, String titleEn) {
this.textRo = textRo;
this.parentId = parentId;
this.titleRo = titleRo;
this.titleEn = titleEn;
}



// Property accessors

public BigDecimal getTextRo() {
return this.textRo;
}

public void setTextRo(BigDecimal textRo) {
this.textRo = textRo;
}

public BigDecimal getParentId() {
return this.parentId;
}

public void setParentId(BigDecimal parentId) {
this.parentId = parentId;
}

public String getTitleRo() {
return this.titleRo;
}

public void setTitleRo(String titleRo) {
this.titleRo = titleRo;
}

public String getTitleEn() {
return this.titleEn;
}

public void setTitleEn(String titleEn) {
this.titleEn = titleEn;
}




public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof AboutEutreeId) ) return false;
AboutEutreeId castOther = ( AboutEutreeId ) other;

return ( (this.getTextRo()==castOther.getTextRo()) || ( this.getTextRo()!=null && castOther.getTextRo()!=null && this.getTextRo().equals(castOther.getTextRo()) ) )
&& ( (this.getParentId()==castOther.getParentId()) || ( this.getParentId()!=null && castOther.getParentId()!=null && this.getParentId().equals(castOther.getParentId()) ) )
&& ( (this.getTitleRo()==castOther.getTitleRo()) || ( this.getTitleRo()!=null && castOther.getTitleRo()!=null && this.getTitleRo().equals(castOther.getTitleRo()) ) )
&& ( (this.getTitleEn()==castOther.getTitleEn()) || ( this.getTitleEn()!=null && castOther.getTitleEn()!=null && this.getTitleEn().equals(castOther.getTitleEn()) ) );
}

public int hashCode() {
int result = 17;

result = 37 * result + ( getTextRo() == null ? 0 : this.getTextRo().hashCode() );
result = 37 * result + ( getParentId() == null ? 0 : this.getParentId().hashCode() );
result = 37 * result + ( getTitleRo() == null ? 0 : this.getTitleRo().hashCode() );
result = 37 * result + ( getTitleEn() == null ? 0 : this.getTitleEn().hashCode() );
return result;
}
}
-------------------------------------------------------------------------
3. AboutEutree.hbm.xml:

<?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 Mar 1, 2006 12:23:49 PM by Hibernate Tools 3.1.0.beta4 -->
<hibernate-mapping>
<class name="eurolegis.AboutEutree" table="&quot;AboutEUTree&quot;" schema="&quot;eurolegis&quot;">
<composite-id name="id" class="eurolegis.AboutEutreeId">
<key-property name="textRo" type="big_decimal">
<column name="&quot;TextRo&quot;" precision="65535" scale="65531" />
</key-property>
<key-property name="parentId" type="big_decimal">
<column name="&quot;ParentId&quot;" precision="65535" scale="65531" />
</key-property>
<key-property name="titleRo" type="string">
<column name="&quot;TitleRo&quot;" />
</key-property>
<key-property name="titleEn" type="string">
<column name="&quot;TitleEn&quot;" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>

------------------------------------------------------------
4. test.jsp:

rez = sess.createQuery("from AboutEutree o where o.parentId = "+id)
.list();
-------------------------------------------------------------
The exception trace is:

org.hibernate.QueryException: could not resolve property: parentId of: eurolegis.AboutEutree [from eurolegis.AboutEutree o where o.parentId = 0]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1265)
at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:279)
at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:372)
at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:539)
at org.hibernate.hql.ast.tree.DotNode.prepareLhs(DotNode.java:221)
at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:172)
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:660)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1215)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4032)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3518)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1758)
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: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:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.createQuery(Unknown Source)
at org.apache.jsp.eurolegis.abouteu_jsp._jspService(org.apache.jsp.eurolegis.abouteu_jsp:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

-----------------------------------------------------------------------------

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 9:33 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:16 am
Posts: 44
Location: Bangalore
But shouldn't this be

rez = sess.createQuery("from AboutEutree o where o.id.parentId = "+id)
.list();

than,

rez = sess.createQuery("from AboutEutree o where o.parentId = "+id)
.list();

Check if it works.

_________________
Please vote if my Postings helps. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 10:40 am 
Newbie

Joined: Wed Mar 08, 2006 7:12 am
Posts: 3
Thanks a lot, it worked!


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