• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with Criteria API

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm working in someone else's code and I have the following object:



And this object (simplified)



The mapping for Health to Project looks like this:



Now, when I try and build a query the simplest form looks like this:



And I am getting the following exception:


org.hibernate.QueryException: could not resolve property: health.overall of: com.aga.dashboard.model.DashboardProject
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
at
org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:59)
at
org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31)
at
org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1350)
at
org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:434)
at
org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:394)
at
org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:45)
at
org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>
(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>
(CriteriaLoader.java:67)


I'm not sure why it thinks health.overall isn't a property of DashboardProject unless it has to do with inheritance. Any help is appreciated.
 
Patel Chintan
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Create alias for "health"..
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Patel Chintan:
Hi,
Create alias for "health"..


That did the trick, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic