Announcement Announcement Module
Collapse
No announcement yet.
fetching max no from hibernate spring database connection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Hi

    Just take a look at http://www.hibernate.org/hib_docs/re.../queryhql.html

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            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]

            Comment


            • #7
              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

              Comment

              Working...
              X