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.
|