Results 1 to 7 of 7

Thread: fetching max no from hibernate spring database connection

  1. #1
    Join Date
    Oct 2004
    Posts
    15

    Default fetching max no from hibernate spring database connection

    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.

  2. #2

  3. #3
    Join Date
    Oct 2004
    Posts
    15

    Default still some confusion

    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.

  4. #4

    Default

    Just use it directly
    Code:
    Query query = session.createQuery("select ....");
    or in a named query.
    The result will be a List with one element in it containing an object array with your data.

  5. #5
    Join Date
    Oct 2004
    Posts
    15

    Default

    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

  6. #6

    Default

    i think in this case the result will be:

    • 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)
    [/list:u:0e467166f5][/list:u:0e467166f5]

  7. #7
    Join Date
    Oct 2004
    Posts
    15

    Default

    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

Similar Threads

  1. Replies: 5
    Last Post: Aug 25th, 2005, 05:37 PM
  2. Replies: 0
    Last Post: Apr 6th, 2005, 08:24 AM
  3. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  4. Replies: 2
    Last Post: Oct 13th, 2004, 02:41 AM
  5. Replies: 7
    Last Post: Aug 21st, 2004, 03:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •