What object type does Spring Hibernate Template execute method return for a counting query on Oracle?

后端 未结 4 873
不知归路
不知归路 2020-12-31 10:19

When run against and Oracle database, what is the runtime type of the object that the following Spring Hibernate Template (Spring 2.5 and Hibernate 3.3.2GA) code returns whe

4条回答
  •  无人及你
    2020-12-31 11:12

    How about

    long value = ((Number)query.uniqueResult()).longValue();
    return Long.valueOf(value);
    

    This would work for all subclasses of Number like Long, Double, Biginteger or BigDecimal.

提交回复
热议问题