Hi,
I am attempting to use a SQLQuery to read from a view. The problem is that while the result list contains the right number of entries, all of them are null. It's as if the class that is being bound to is not being instantiated.
For example, if there are 35 rows that match the query in the database, the result list is of size 35. All of them null.
I have tried to break this down to the simplest test case:
NamedQuery:
<sql-query name="getMatchingScholars">
<return alias="s" class="edu.yale.yis.scholar.person.Person">
<return-property name="id" column="personId"/>
<return-property name="netId" column="netId"/>
<return-property name="personName.lastName" column="lastName"/>
<return-property name="personName.firstName" column="firstName"/>
<return-property
name="personName.middleName"column="middleName"/>
<return-property name="personName.suffix" column="suffix"/>
select
s.yisScholarId as personId,
s.fsaAtlasId as netId,
s.lname as lastName,
s.fname as firstName,
s.mname as middleName,
s.NameSuffix as suffix
from v_scholar_search s
where s.lname = 'Kim'
</sql-query>
Here is the code that is run:
List results = session.getNamedQuery("getMatchingScholars").list();
Other details are below.
Any insight you can provide would be greatly appreciated. Thanks for your help.
--------------------------------------------------------
Hibernate version:
3.05
Mapping documents:
<hibernate-mapping package="edu.yale.yis.scholar.person" default-access="property" default-lazy="false">
<class name="edu.yale.yis.scholar.person.Person" table="ES_PERSONS">
<id name="id" column="personId">
<generator class="native"/>
</id>
<property name="netId" type="string" column="netId"/>
<component name="personName"
class="edu.yale.yis.scholar.person.PersonName">
<property name="firstName" type="string" column="firstName"/>
<property name="middleName" type="string" column="middleName"/>
<property name="lastName" type="string" column="lastName"/>
<property name="suffix" type="string" column="suffix"/>
</component>
<joined-subclass .....
Code between sessionFactory.openSession() and session.close():
List results =
session.getNamedQuery("getMatchingScholars").list();
Name and version of the database you are using:
SQLServer 2000
The generated SQL (show_sql=true):
select
s.yisScholarId as personId,
s.fsaAtlasId as netId,
s.lname as lastName,
s.fname as firstName,
s.mname as middleName,
s.NameSuffix as suffix
from v_scholar_search s
where s.lname = 'Kim'
-----------------------------------------------------------------
|