Hi,
I want to get a (paginated) list of account numbers from a temporary report table that contains a list of deals. A row has got reportid, a deal, and an account:
Code:
CREATE TABLE REPORT ( REPORTID INTEGER, DEAL INTEGER, ACCOUNT VARCHAR(25))
I use the query:
Code:
SQLQuery query = session.createSQLQuery("select distinct ACCOUNT from REPORT where REPORTID = ? ORDER BY ACCOUNT ");
[b]query.setFirstResult(startRow);[/b]
if (blockSize > 0) {
[b]query.setMaxResults(blockSize);[/b]
}
List<String> accounts = query.list();
The problem ist: depending on the database the accounts list object does NOT contain only strings.With Oracle 10g the list contains a list af arrays; every array has a length of 2 with object[0] : ACCOUNTNO, object[1]: Row-Number (BigDecimal)
For Oracle Hibernate performs a query like this:
Code:
select * from ( select row_.*, rownum rownum_ from ( select distinct ACCOUNT from REPORT where REPORTID = ? ORDER BY ACCOUNT ) row_ where rownum <= ?) where rownum_ > ?
With
DB2 the query generated by Hibernate is
even different: the order of ACCOUNT and row number is different: the row number comes first and is a BigInteger.
Trying all this with H2 everything is as expected.
Is there any solution to handle these database specific problems?
Do I have to write database specific code for inspecting the query results?I cannot believe...
Please help. Thanks!