rrazd rrazd - 1 year ago 120
Java Question

What is Object/relational mapping(ORM) in relation to Hibernate and JDBC?

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download