-->
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 returning null sets for a mapping
PostPosted: Tue Jun 09, 2009 4:40 am 
Newbie

Joined: Tue Jun 09, 2009 4:03 am
Posts: 2
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.


Top
 Profile  
 
 Post subject: Re: Hibernate returning null sets for a mapping
PostPosted: Wed Jun 10, 2009 2:09 am 
Newbie

Joined: Tue Jun 09, 2009 4:03 am
Posts: 2
Problem solved with information gleaned from

https://forums.hibernate.org/viewtopic. ... &view=next
and
http://forum.springsource.org/showthread.php?t=36426

Basically if my view returned a null anywhere the entire row was null. This is why I mention another view working fine, those rows did not have nulls. It turned out they were being problematic after all.

I have to jump through some more hoops on the Java side of things to return MyDataClassVw objects instead of having hibernate do that for me automatically

-Matt


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.