Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Can someone explain, in layman terms, what is Object/relational mapping(ORM) in relation to Hibernate and JDBC?

Diagrams would be especially helpful for understanding...

EDIT: I found this via google for Hibernate ORM, can someone confirm that it is accurate and a good representation of how ORM is used.

enter image description here

src: http://software-carpentry.org/3_0/summary.html

share|improve this question

1 Answer 1

up vote 10 down vote accepted

ORM allows you to use java objects as representation of a relational database. It maps the two concepts (object-oriented and relational)

Hibernate is an ORM framework - you describe how your objects are represented in your database, and hibernate handles the conversion.

JDBC is the API for database access, and it works "in a relational way" - you query tables and get rows and columns back. Hibernate uses JDBC under the hood to fetch the data and later convert it to objects.

A jdbc ResultSet has multiple records, and each record has a set of columns. In hibernate this becomes of List<SomeClass> where SomeClass has a field for every column in the database table, and there is one instance ofSomeClass` per database record.

share|improve this answer
    
excellent answer! any chance you can include a diagram of app using ORM with Hibernate and contrast it with a diagram of app using JDBC? –  rrazd Aug 15 '11 at 17:09
    
I don't think it will be a good diagram - ORM uses objects; databases uses tables. Right now I can't think of a good way to illustrate the difference graphically –  Bozho Aug 15 '11 at 17:14
    
can you confirm the posted pic is legitimate for Hibernate ORM –  rrazd Aug 15 '11 at 17:25
    
yes, it is fine. But it should be accompanies by a textual explanation. –  Bozho Aug 15 '11 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.