Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

couldn't resolve property exception in Hibernate

 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This query is expected to work
SELECT relocationAssets from RelocationAssets as relocationAssets,RelocationRequests as reloctionRequests where relocationAssets.reloctionRequests.relocationRequestKey=:relocationRequestKey
but it is giving me exception,

DEBUG - compiling query
net.sf.hibernate.QueryException: could not resolve property: reloctionRequests of: com.toshiba.phoenix.relocation.domainmodel.RelocationAssets [SELECT relocatio
nAssets from com.toshiba.phoenix.relocation.domainmodel.RelocationAssets as relo
cationAssets,com.toshiba.phoenix.relocation.domainmodel.RelocationRequests as re
loctionRequests where relocationAssets.reloctionRequests.relocationRequestKey=:r
elocationRequestKey]
at net.sf.hibernate.persister.AbstractPropertyMapping.toType(AbstractPro
pertyMapping.java:38)
at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpress
ionParser.java:249)
at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.
java:123)
at net.sf.hibernate.hql.WhereParser.doPathExpression(WhereParser.java:34
2)
at net.sf.hibernate.hql.WhereParser.doToken(WhereParser.java:374)
at net.sf.hibernate.hql.WhereParser.token(WhereParser.java:259)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.ja
va:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149
)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138
)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.
java:295)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1572)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:49)


Is this happening because of bug in hibernate version 2.0?, Because reloctionRequests property exists in RelocationAssets class. And while persisting RelocationAssets.setRelocationRequest(reloctionRequests) it works fine.

What could be work around for this.
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My methods in
RelocationAssets are as follows
which is working fine while stroing RelocationRequests object.

/**
* @hibernate.many-to-one
* column="RELOC_REQUEST_KEY"
* class="com.toshiba.phoenix.relocation.domainmodel.RelocationRequests"
*/

public RelocationRequests getReloctionRequest() {
return reloctionRequests;
}
/**
* @param reloctionRequest The reloctionRequest to set.
*/
public void setReloctionRequest(RelocationRequests reloctionRequest) {
this.reloctionRequests = reloctionRequest;
}
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have a misnamed property.

In the HQL the request property is called "relocationAssets.reloctionRequests", but in the bean, the getter method is called getReloctionRequest(). [Note the missing 's'].
 
Jignesh Patel
Ranch Hand
Posts: 626
Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott,
You are right, it works fine now.

thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic