aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate newbie question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate newbie question" Watch "Hibernate newbie question" New topic
Author

Hibernate newbie question

Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 177
Good day,

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!
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

Is this homework?

I am not sure what you are looking for.

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.


[How To Ask Questions][Read before you PM me]
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 177
Thanks Bill,

for item1, it purely just save the data like a lookup table for key and name reference, it doesn't have relationship like 1:1 or 1:m, can we save the set without define relationship?

Is there any recommended site or book i should reference? there are many but i would appreciated if you can specify it since i got limited time here for this.

FYI, it is commercial project where my colleague just resign in short notice and i have cover it for deadline
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1632
    
    7

can we save the set without define relationship?


Sure @Table and @Column annotations (or equivalent mapping file if using xml) would be all you need in that case.


Is there any recommended site or book i should reference?


I like Pro JPA2

There are lots of sites out there. Often times though the one that will help depends on the problem you are having. Google is your best friend in this case.

Good luck!
Nakataa Kokuyo
Ranch Hand

Joined: Jul 24, 2011
Posts: 177
Thanks Bill , many thanks !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate newbie question
 
Similar Threads
need help in connection performance...
Struts Validation for non formdata
SQL syntax error
problem with bulk update and auto_increment
org.hibernate.exception.SQLGrammarException: could not insert: