-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate returns list of nulls
PostPosted: Thu Jul 10, 2014 3:48 am 
Newbie

Joined: Tue Jul 01, 2014 7:25 am
Posts: 4
Hi,
I've already asked this question on SO (http://stackoverflow.com/q/24657919/1140338).

I'm using hibernate as an ORMapper. 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.

Does anyone know what might be the problem here?


Top
 Profile  
 
 Post subject: Re: Hibernate returns list of nulls
PostPosted: Thu Jul 10, 2014 8:57 am 
Newbie

Joined: Tue Jul 01, 2014 7:25 am
Posts: 4
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.