• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Hibernate mapping problem

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, i have the following DB table, very simple

CLASS
-------
class_id
class_name


STUDENT
---------
student_id
student_name


STUDENT_STATUS
--------------
student_id
class_id
midterm_score
final_score


my mapping is as follow


The whole point is when a user click on any of the classes, an html table will show the list of students with their name, midterm score and final scores. I just start using Hibernate yesterday, and not sure how to fix the mapping to also retrieve the midterm_score and final_score. Any help is appreciated. Thank you

[ Edited to include code tags - Paul Sturrock ]
[ November 09, 2006: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi le i think you should add the many-to-many relation tag

attribute for the student table .and then you have to use

the link table properly .i think its better to play

with one-to-many in the initial stage.

regards
amir
 
Vu Le
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was thinking of breaking up the STUDENT_STATUS table into:

STUDENT_STATUS
--------------
student_id
class_id
entry_id (Primary Key)


STATUS
------------
entry_id (Primary Key)
midterm_score
final_score


... and use one-to-one mapping. I think it will work but just a waste to have another table just for hibernate to work. Does anyone has a solution to not having to split the table. Thank you
 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well le

you can try with this set-up

two tables having primary and foregin key each other

(i.e) table1 Pk is FK in table2
and table1 FK is PK in table2


regards
amir
 
reply
    Bookmark Topic Watch Topic
  • New Topic