-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate Set is missing rows
PostPosted: Tue Jul 22, 2014 4:54 pm 
Newbie

Joined: Tue May 02, 2006 9:56 pm
Posts: 6
I have a one-many relationship that when i access via the POJO Set, it is missing data. If i directly query for the Set then all the data is retrieved propertly.

Code:
<hibernate-mapping>
    <class name="domain.StudentUser" table="student_user" >

....

    <set name="studentCourseses" inverse="true" order-by="import_date ASC">
        <key>
            <column name="student_userid" length="15" not-null="true" />
        </key>
        <one-to-many class="domain.StudentCourses" />
    </set>
</hibernate-mapping>


The StudentCourses Set in the StudentUser POJO is always missing the same rows, so its not randomly choosing rows to remove. Most, but not all of the StudentUser's experience this behavior.

As mentioned, a direct query works as shows here vs the incorrect data method

Code:
for(StudentCourses course : getStudentService().retrieveStudentByID("861043440").getStudentCourseses()) {  //MISSING DATA
         System.out.println(course +" - "+course.getTerm());
      }
      
      for(StudentCourses course : (List<StudentCourses>)getStudentService().getStudentCoursesDAO().findByProperty("studentUser.studentUserid", "861043440")) {  //CORRECT ALL DATA
         //System.out.println(course +" - "+course.getTerm());
      }


So there is something with the relationship in the mapping file because the data is there and is correctly displayed when i query the StudentCourses table directly. This is a huge database yet this is the only table/relationship that is experiencing this type of issue, so I really have no clue what the problem is as all the data looks correct.

I am using Hibernate 3.5.3. Sorry if i have not provided enough info, but since I'm so lost on this issue I don't know where to start or whats important to talk about. Please ask for whatever information you may need to assist me.

Thanks!

If it helps, here is the mapping for the StudentCourses table

Code:
<hibernate-mapping>
<class name="domain.StudentCourses" table="student_courses" >
    <id name="id" type="integer">
        <column name="id" />
        <generator class="native" />
    </id>
    <many-to-one name="classLevel" class="domain.ClassLevel" fetch="select">
        <column name="class_level_code" length="2" not-null="true" />
    </many-to-one>
    <many-to-one name="academicTerm" class="domain.AcademicTerm" fetch="select">
        <column name="academic_term_id" not-null="true" />
    </many-to-one>
    <many-to-one name="studentUser" class="domain.StudentUser" fetch="select">
        <column name="student_userid" length="15" not-null="true" />
    </many-to-one>
    <property name="academicYear" type="integer">
        <column name="academic_year" not-null="true" />
    </property>
    <property name="term" type="string">
        <column name="term" length="8" not-null="true" />
    </property>
    <property name="title" type="string">
        <column name="title" length="64" not-null="true" />
    </property>
    <property name="prefix" type="string">
        <column name="prefix" length="8" not-null="true" />
    </property>
    <property name="courseNum" type="string">
        <column name="course_num" length="8" not-null="true" />
    </property>
    <property name="suffix" type="string">
        <column name="suffix" length="8" />
    </property>
    <property name="sectionNum" type="string">
        <column name="section_num" length="8" />
    </property>
    <property name="units" type="double">
        <column name="units" precision="4" not-null="true" unique="true" />
    </property>
    <property name="letterGrade" type="string">
        <column name="letter_grade" length="6" not-null="true" />
    </property>
    <property name="qtrGpa" type="double">
        <column name="qtr_gpa" precision="4" scale="3" not-null="true" />
    </property>
    <property name="cumGpa" type="double">
        <column name="cum_gpa" precision="4" scale="3" not-null="true" />
    </property>
    <property name="importDate" type="timestamp">
        <column name="import_date" length="19" />
    </property>
    <property name="sourceFileName" type="string">
        <column name="source_file_name" length="128" />
    </property>
    <property name="timeStamp" type="timestamp">
        <column name="time_stamp" length="19" not-null="true">
            <comment>on update CURRENT_TIMESTAMP</comment>
        </column>
    </property>
</class>


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

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.