I have to fetch max no of a column value from a table into an integer field.
For example
select max(column1) from table1 where column2="condition1"
Is there any way from hibernate spring to do the needful.
Your help will be appreciated.
Printable View
I have to fetch max no of a column value from a table into an integer field.
For example
select max(column1) from table1 where column2="condition1"
Is there any way from hibernate spring to do the needful.
Your help will be appreciated.
Hi
Just take a look at http://www.hibernate.org/hib_docs/re.../queryhql.html
IU have seen the url before and this one matches my case
select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)
from eg.Cat cat
but here how to execute it and what kind of result will it return.
Will it return List or so.
Just use it directly
or in a named query.Code:Query query = session.createQuery("select ....");
The result will be a List with one element in it containing an object array with your data.
what kind of list will it return with
select avg(cat.weight), sum(cat.weight), max(cat.weight), count(cat)
from eg.Cat cat
Will it contain a list with 4 integer objects. The above example is with Hibernate documentation
i think in this case the result will be:
[/list:u:0e467166f5][/list:u:0e467166f5]
- List (size=1) cause there's only one result row
[list:0e467166f5]
--> Object []
[list:0e467166f5]
--> Double (avg)
--> Integer/Double (sum) depends on your data
--> Integer/Double (max) depends on your data
--> Integer (count)
Thanks for your effort, I will have to try this and will take atleast 7 to 8 days for me because of the environment here. Thanks again