I'm facing dilemma of short timeline about 2-3 days to handle left over task, while I still picking up on Hibernate, I need to handle three scenario but i'm not sure how to write the correct hbm config file.
The scenarios :
1. having set of records under a collection - set, these record will need to insert into table-SchoolReference and generate the id in incremental way. the Db will store many records with format <schoolID, schoolName>, in this case, studentID is auto generated.
2. have a list with records of few columns which need to be insert into another table-SchoolConversion. Scenario: student from this school change to another school, format <beforeSchoolID, beforeSchoolName, afterNewSchoolID, AfterNewSchoolName>.
3. When giving the school id, I need to find from schoolconversion table, what are the related schoolID for before and after conversion.
Appreciated your guidance on this, thanks in advance!
1. I would write out your requirements on some paper or a white board and start figuring out what your domain objects should look like. Applications should be written in terms of the domain model, while you are doing this forget all about tables and columns. Your application should not be bound to the relational model. You should operate on the domain model without having to express it in the relational language of tables, columns, and keys.
2. Next forget about everything you were doing in #1 and think about table design. What data do you have to store and what is the most efficient way to store it ? Create the tables accordingly.
3. Now after 1 and 2 you map the domain objects to the tables and columns. This is the step where you will annotate your domain objects or create a hibernate mapping xml.
It sounds to me like you might be skipping steps 1 and 2. I would encourage you to back up a bit and do those first two steps first and then try step 3. If you encounter specific difficulties post back with them.