Hibernate Annotation

How to call max function in hibernatedaosupport using getHibernateTemplate().find

for exp :- getHibernateTemplate().find("from JobworkflowdtlORM  where  V_CVDPL_NO='EM090800013' and maxelement(JobworkflowdtlORM.linenumber) ");

ajaygundAsked:
Who is Participating?
 
Sathish David Kumar NConnect With a Mentor ArchitectCommented:
His question is
<<<<<How to call max function in hibernatedaosupport using getHibernateTemplate().find

i gave answer for that eg was
getHibernateTemplate().find("select  max(inlineNo) from  JobworkflowdtlORM  where  V_CVDPL_NO=' "+EM090800013 " ' ");

He gave the query as example only thats clear in his question .I gave sloution how we use max funtion in getHibernateTemplate for his example .

But he use the same(example) as his query and come for another question !!
that have an error !!
thats is his next question

i gave soluion for that !!

V_CVDPL_NO this filed not present in his POJO class so i mention that in my last post of my answer .

0
 
Sathish David Kumar NArchitectCommented:
getHibernateTemplate().find("select  max(inlineNo) from  JobworkflowdtlORM  where  V_CVDPL_NO=' "+EM090800013 " ' ");
0
 
ajaygundAuthor Commented:
I have Use this code :- getHibernateTemplate().find("select  max(inlineNo) from  JobworkflowdtlORM  where  V_CVDPL_NO=' "+EM090800013 " ' ");


But show Error :-
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode
 \-[AGGREGATE] AggregateNode: 'max'
    \-[IDENT] IdentNode: 'inlineNo' {originalText=inlineNo}

Please give me solution .

Thanks in advance.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Sathish David Kumar NArchitectCommented:
Can u tell me what is this one ??

1.V_CVDPL_NO ?? is it the property in Bean calss ??

2. is it string value ??

3. is there any filed name called V_CVDPL_NO in ur JobworkflowdtlORM
0
 
Sathish David Kumar NArchitectCommented:
which one filed  u want to get the max value ??

I gave the example only !!

can u post the POJO of JobworkflowdtlORM
0
 
ajaygundAuthor Commented:
/**
 *
 */
package com.dummy.orm;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.GenericGenerator;

/**
 * @author rajesh.bihade
 * date 10 Sept 2009
 */
      
      @Entity
      @Table (name="JOB_WORK_FLOW_DTL")      
      @org.hibernate.annotations.Entity (dynamicUpdate = true, dynamicInsert = true)
public class JobworkflowdtlORM implements Serializable{

      
      @ Id
      @ GeneratedValue (generator = "gen")
      @ GenericGenerator (name = "gen", strategy = "increment")
      @ Column(name="V_CVDPL_NO")
      private String order_no2 = null;
      


    @ OneToMany (cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "jobworkflowdtlORM")
      @ BatchSize (size = 5)
    private Set <CoreteamORM> coreteamORM = new HashSet <CoreteamORM> ();          
      //private CoreteamORM coreteamORM;
   
    @ Column (name = "N_LINENUMB",  length = 50, insertable = true, updatable = true, nullable = false)
   
      private String  linenumber  =null      ;
 

      /**
       * @return the order_no
       */
      public String getOrder_no2() {
            return order_no2;
      }

      /**
       * @param order_no the order_no to set
       */
      public void setOrder_no2(String order_no2) {
            this.order_no2 = order_no2;
      }

      
      

      /**
       * @return the coreteamORM
       */
      public Set<CoreteamORM> getCoreteamORM() {
            return coreteamORM;
      }

      /**
       * @param coreteamORM the coreteamORM to set
       */
      public void setCoreteamORM(Set<CoreteamORM> coreteamORM) {
            this.coreteamORM = coreteamORM;
      }

      /**
       * @return the linenumber
       */
      public String getLinenumber() {
            return linenumber;
      }

      /**
       * @param linenumber the linenumber to set
       */
      public void setLinenumber(String linenumber) {
            this.linenumber = linenumber;
      }

      

      
      /**
       * @return the coreteamORM
       */
      /**public CoreteamORM getCoreteamORM() {
            return coreteamORM;
      }

      /**
       * @param coreteamORM the coreteamORM to set
       */
      /*
      public void setCoreteamORM(CoreteamORM coreteamORM) {
            this.coreteamORM = coreteamORM;
      }

 */
      
      
}
0
 
Sathish David Kumar NArchitectCommented:
what is V_CVDPL_NO ??

i cant find V_CVDPL_NO  in bean ur class??
0
 
Sathish David Kumar NArchitectCommented:
i gave correct solution
0
 
Sathish David Kumar NArchitectCommented:
0
 
Sathish David Kumar NArchitectCommented:
so that only error was coming !!
0
 
Sathish David Kumar NArchitectCommented:
i didnt get any updated msg !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.