-->
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.  [ 2 posts ] 
Author Message
 Post subject: maxIndex in HQL query
PostPosted: Fri Feb 25, 2011 8:01 am 
Newbie

Joined: Fri Feb 25, 2011 7:35 am
Posts: 1
Hi,
I've got 2 tables:
1. APPLICATION - contains some basic data about application documents.
2. FLOW_REGIST - contains data about state of a document: status, date of change to this status, user who made a change

The releationship is (application)1:m(flow_regist), so each application has number of states.
Now, I'd like to retrive all applications which have last state(the latest insertDate) in a specific status
I created some hql:
Code:
"select appl.apSubject, appl.apShortDesc from PintApplication as appl "
      +      " left join  appl.pintFlowRegisters as reg "
      +      " where " +
            " reg.frInsertDate[ maxindex(reg.frInsertDate) ].frStatusNew = :status"

But as a result of this hql I get:
Code:
Caused by: org.hibernate.MappingException: Property maxIndex does not exist in collection model.PintApplication.pintFlowRegisters
   at org.hibernate.hql.ast.tree.FromElementType.getPropertyType(FromElementType.java:282)
   at org.hibernate.hql.ast.tree.FromElement.getPropertyType(FromElement.java:386)
   at org.hibernate.hql.ast.tree.MethodNode.resolveCollectionProperty(MethodNode.java:114)
   at org.hibernate.hql.ast.tree.MethodNode.collectionProperty(MethodNode.java:95)
   at org.hibernate.hql.ast.tree.MethodNode.resolve(MethodNode.java:44)
   at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:835)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:2328)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1287)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4350)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExprLhs(HqlSqlBaseWalker.java:4830)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.addrExpr(HqlSqlBaseWalker.java:4311)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1212)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4041)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3525)
   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)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)


Could you explain me: do I use maxIndex function correctly?


Top
 Profile  
 
 Post subject: Re: maxIndex in HQL query
PostPosted: Mon Feb 28, 2011 4:36 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
This is the wrong forum. You should ask on the Hibernate User forum instead. This forum is for Hibernate Search and Validator.
That said, have you double checked that pintFlowRegisters properly mapped as a list?

--Hardy


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