I'm unable to get the following query to work from within Hibernate:
Code:
select distinct item.varchar_value_5 from merchandise.ds_item(6) as item;
I've tried a variety of approaches, including:
Code:
session.createSQLQuery(
"SELECT {item}.varchar_value_5 FROM merchandise.ds_item(6) as {item}",
"item",
com.publishworks.merchandise.Item.class
).list();
Which produces a
[java] java.lang.NullPointerException
Complaining:
[java] org.postgresql.util.PSQLException: The column name dsrc_id0_ not found.
Yes, dsrc_id is part of the primary key for item.
So it seems that, quite naturally, hibernate wants to create the item object (or at least its id) when using an {item} reference in a query.
I noticed, however, that hibernate does support querys like:
Code:
select distinct cat.name from eg.Cat cat
And am wondering if there is a way to get similar support with direct sql without dropping down to jdbc.