Hi!
I have a mapping to an (Oracle) view and have been noticing very weird behaviour. If I do the following HQL inside my DAO (where MyDataClassVw is a view)
Code:
from MyDataClassVw
I get back (according to MyEclipse 7.1.1) results of <null> equal to the total amount of results in the view. If I constrain the HQL to retrieve only a few columns
Code:
select view.id.submitDate, view.id.attendeeLicence, view.id.name from MyDataClassVw view where view.id.courseId = ? and view.id.attendanceDate = ?
I will get back a meaningful primitive data set. Executing the generated SQL in TOAD returns the results I am looking for also... but not as plain nulls!
Can anyone suggest what might be wrong with my mapping or what I have missed? Why do I get back data not "typed" correctly? This presents issues when trying to use it in my Java. I have other classes set up in the same vein and everything seems to work as expected.
Some more information:
MyDataClassVw.hbm.xml:
Code:
<hibernate-mapping>
<class name="au.mycompany.businessmodel.MyDataClassVw" table="MYCOURSE_VW" schema="MYCOURSE">
<composite-id name="id" class="au.mycompany.businessmodel.MyDataClassVwId">
<key-property name="courseAttendanceId" type="java.lang.Long">
<column name="COURSE_ATTENDANCE_ID" precision="12" scale="0" />
</key-property>
<key-property name="courseId" type="java.lang.Long">
<column name="COURSE_ID" precision="12" scale="0" />
</key-property>
<key-property name="attendeeLicenceType" type="java.lang.String">
<column name="ATTENDEE_LICENCE_TYPE" length="10" />
</key-property>
<key-property name="attendeeLicenceNumber" type="java.lang.Long">
<column name="ATTENDEE_LICENCE_NUMBER" precision="12" scale="0" />
</key-property>
<key-property name="attendeeLicence" type="java.lang.String">
<column name="ATTENDEE_LICENCE" length="50" />
</key-property>
<key-property name="attendanceDate" type="java.util.Date">
<column name="ATTENDANCE_DATE" length="7" />
</key-property>
<key-property name="submitDate" type="java.util.Date">
<column name="SUBMIT_DATE" length="7" />
</key-property>
<key-property name="adminLicenceId" type="java.lang.Long">
<column name="ADMIN_LICENCE_ID" precision="12" scale="0" />
</key-property>
<key-property name="courseApprovalNumber" type="java.lang.String">
<column name="COURSE_APPROVAL_NUMBER" length="80" />
</key-property>
<key-property name="courseName" type="java.lang.String">
<column name="COURSE_NAME" length="250" />
</key-property>
<key-property name="points" type="java.lang.Double">
<column name="POINTS" precision="3" />
</key-property>
<key-property name="mandatoryFlag" type="java.lang.String">
<column name="MANDATORY_FLAG" length="1" />
</key-property>
<key-property name="providerLicenceId" type="java.lang.Long">
<column name="PROVIDER_LICENCE_ID" precision="12" scale="0" />
</key-property>
<key-property name="cat4Flag" type="java.lang.String">
<column name="CAT4_FLAG" length="1" />
</key-property>
<key-property name="name" type="java.lang.String">
<column name="NAME" length="300" />
</key-property>
<key-property name="entityName" type="java.lang.String">
<column name="ENTITY_NAME" length="300" />
</key-property>
<key-property name="surname" type="java.lang.String">
<column name="SURNAME" length="100" />
</key-property>
<key-property name="firstName" type="java.lang.String">
<column name="FIRST_NAME" length="50" />
</key-property>
<key-property name="otherNames" type="java.lang.String">
<column name="OTHER_NAMES" length="100" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>
Inside hibernate.cfg.xml there is a mapping entry for the above xml file (and others)
Not sure what else I need to include as everything from the Java side is tied down nicely. I simply cannot get back from this one particular view the data I want in a meaningful way. Other views -> no such problem.