Hibernate返回一个数组返回重复的列

时间:2014-02-21 17:31:02

标签: java oracle hibernate

我用Hibernate执行以下查询,并且返回的对象数组在位置2和3中具有相同的值,而在DB中这些值是不同的。数据库是Oracle,Hibernate是3.2.6版。这只发生在生产和特定客户(使用WebSphere),在开发和其他客户中工作正常。

String sql = " SELECT acc.account_code," +
             "        acct.description, " +
             "       ( SELECT SUM(item_amount)" +
             "         FROM gem_book_entry_item bi, gem_document d" +
             "         WHERE account_id = acc.dboid AND " +
             "               account_sign = 1 AND " +
             "               bi.document_id = d.dboid AND " +
             "               d.state_id = :definitive AND " +
             "               (d.internal_reference IS NULL OR d.internal_reference NOT IN (:references)) AND " +
             "               d.posting_approval_date <= :refDate" +
             "       ) ," +
             "       ( SELECT SUM(item_amount)" +
             "         FROM gem_book_entry_item bi, gem_document d" +
             "         WHERE account_id = acc.dboid AND " +
             "               account_sign = -1 AND " +
             "               bi.document_id = d.dboid AND " +
             "               d.state_id = :definitive AND " +
             "               (d.internal_reference IS NULL OR d.internal_reference NOT IN (:references)) AND " +
             "               d.posting_approval_date <= :refDate" +
             "        ) ," +
             "        acc.init_balance" +
             " FROM gem_account acc, gem_account_t acct " +
             " WHERE acc.dboid = acct.dboid AND " +
             "       acc.institution_id = :institutionId AND " +
             "       acc.period_code = :periodCode AND " +
             "       acct.lang = :langId " ;

1 个答案:

答案 0 :(得分:0)

这是一个Hibernate错误:

https://hibernate.atlassian.net/browse/HHH-4956

使用别名是解决方法。