-->
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: Common practice, views or normal mapping on multiple joins
PostPosted: Sun Feb 14, 2010 12:27 pm 
Newbie

Joined: Wed Aug 01, 2007 4:53 pm
Posts: 11
I have this rather complicated datamodel and i don't know what is common practice for moddeling it in hibernate...
I'll explain the model:

I'm working on an application for my girlfriend who is a teacher. She must be able to enter grades for her students for tests.
This is the datamodel:

Student (id, name)
Class (id,name)
student_classes(id,student_id,class_id) (a student can be part of multiple classes)
test(id,name,class_id)
grade (id,test_id,student_id,grade)

I have made the part were i can get the students from a class with a many to many relation using a set:

Code:
<set cascade="all" fetch="select" lazy="false" name="leerlingen"
   optimistic-lock="false"  sort="unsorted" table="student_classes">
   <key column="class_id"/>
   <many-to-many class="Student" order-by="name" column="student_id" unique="false"/>
  </set>



Now i want to get a set of grades from a student.
I could create a view and create a model from that view in hibernate. WHen i want to add grades i would also have to model the normal classes for grades and tests instead of using the view.

So normal i would create a query joining student, test and grade.
But... When a student was ill the day he must do the test he will not have an entry in the grade so i would have to use outer joining to also show that test in the list.
WHat should i use for this?
Just create a view in my DB (mysql 5) or use normal tables and model the complete thing in hibernate? If the last... What should i use?
Can i create a single mapping to i can get a set of grader from the students so i will have a getGrades() from the student that gives me the title of the test and the grade for that student?


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.