Quantcast
Channel: Java Programming Forum - Learn Java Programming - Hibernate
Viewing all articles
Browse latest Browse all 76

Hibernate returns list of nulls although executed SQL returns values

$
0
0
Hi everyone,

I have a problem with hibernate (I also asked this on SO). I'm using hibernate as an ORMapper and I want to execute an actually rather simple hql query:

Code:

SELECT a
FROM Foo a
WHERE a.status = :A0status
ORDER BY a.bookingTypeCode ASC,
        a.priority ASC

This hql query is then converted into a sql query which looks something like this:

Code:

select a.*
from Foo a
where a.status='A'
order by a.bookingtypecode ASC,
        a.priority ASC

When I execute the sql on the oracle database using the Oracle SQL Developer I get 17 rows returned. However, when I execute the hql query (using the list method of a Query I get a list of 17 elements that are all null. Although the number of elements is correct, not a single one of the elements is actually loaded.

This is the way I create and execute my query:

Code:

// the hql query is stored in the hqlQuery variable;
// the parameter are stored in a Map<String, Object> called params
Query hQuery = hibSession.createQuery(hqlQuery);
for (Entry<String, Object> param : params.entrySet()) {
    String key = param.getKey();
    Object value = param.getValue();
    hQuery.setParameter(key, value);
}

List<?> result = hQuery.list();

The result I'm getting after executing query.list();

I've recently upgrade from hibernate 3.2 to 4.3.5. Before the upgrade everything worked fine. After the upgrade I get this error. Also this error seems to only occur with one entity (all ~200 other entities work correctly).

Does anyone know what might be the problem here?

Viewing all articles
Browse latest Browse all 76

Trending Articles