-->
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 mapping
PostPosted: Thu Oct 04, 2012 7:45 pm 
Newbie

Joined: Thu Oct 04, 2012 7:20 pm
Posts: 1
Hi I am new to Hibernate, but have JPA exp. Here is the thing I need to do.
I have 3 tables called Instructor, student, Schedule. Instructor, student are on same schema say Schema1.
Schedule is another schema, Schema2.
Instructor has 4 COMPOSITE KEYS(PKs). same as with student and schedhule.
here is sql:(Here I am just giviing the columns that I want to join but there are many also some of the remaining are composite keys)
SELECT Schema1.Instructor I, Schema1.student s, schema2.Schedule sc
WHERE I.Id=s.Id and I.code = s.code and I.className = Sc.className (all are one-one mapping) and I.DeptNo = ? (means we are passing)

NOW Since I am new to Hibernate I have so many questions:
Basic questions:
1. Do I have to have map all columns which are composite keys? or simply can I select the one I need and omit other columns?
2. How to write the hbm.configs for those? I have to use xml only NO annotations pls.

Here are thoughts:
1.Create pojo for Instructor
2.inside Instructor declare/get/set 2 pojos as private Student student, private Schedule schedule;
3.and in Student, Schedule pojos declare/add get/set for what the fields that we need
4. in .hbm.xml how can I join those?Do I have to have 3 hbm.xml and those 3 are configured in hbm-config-xml?
5. finally in instructor class use CreateCriteria then add those 2 pojos Student, Schdule as alias?
will this work? pls give me some input, I am working on my class project.


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.