Hibernate returns list of nulls although executed SQL returns values
hibernate, java, oracle, sql
Solution
I've set the Log level of hibernate to TRACE and found the problem. It was actually a mapping/logic/database error. The primary key consisted of two columns (according to the entity class) and one of these columns was nullable. However a primary key can never be nullable. Therefore hibernate always returned null.
Problem
I'm using hibernate as an ORMapper. I want to execute an actually rather simple hql query: ``` 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: ``` 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: ``` // 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(); ``` Does anyone know what might be the problem here? Update 1 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.