Uploaded image for project: 'Apache MetaModel'
  1. Apache MetaModel
  2. METAMODEL-1164

How to cast result of a query containing an aggregate function using apache metamodel

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.5.4
    • Fix Version/s: None
    • Labels:
      None

      Description

      I am new to apache metamodel. And I need to run following query using apache metamodel.

      select sum(cast(columnName as decimal)) from table;"
      

      I know that a query containing simple sum function looks like the one given below:

      Query query = dataContext.query().from(table).select(FunctionType.SUM, table.getColumnByName(columnName)).toQuery();
      

      But I need to use a cast function because depending on the number of records in particular table the result of the sum can be too big than a value which an integer can hold. Thus causing an exception "Arithmetic overflow error converting expression to data type int." to be thrown when there are millions of records in a table. Can anyone tell me how to apply a cast function when composing a query to be executed with apache metamodel.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            santosh1 santoshnagda
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development