Hibernate In Action

Notes from ‘Hibernate in Action’:
Chapter 1:

  • The Paradigm Mismatch
  1. Granularity – SQL databases only support two levels of granularity : tables & columns
  2. Subtypes – SQL databases have no notion of inheritance, a foreign key constraint refers to exactly one table
  3. Identity – Java has two notions of sameness : object identity (==) & equality. Identity in the database is based on primary keys
  4. Associations – OOP represents associations as object references which are directional. Database represent associations as foreign key columns. Table relationships have multiplicity : one-to-one, one-to-many, many-to-many (require link table).
  5. Data navigation – OOP navigation is done by following object reference between instances. The depth is determined by how many tables we retrieved from the database (executing one statement per node leads to inefficient performance).
  • Alternatives to ORM
    • Hand-coded SQL/JDBC – requires high degree of effort
    • Serialization – requires deserializing the entire network of objects
    • Object Oriented DB – not widely adopted
    • XML – variant of the serialization theme, object/hierarchial mismatch

     

  • Hibernate/EJB/JPA
    • EJB 3.0 specification comes in several parts
    • The second part deals with persistence exclusively
    • Java Persistence API (JPA) – javax.persistence
    • EJB products may implement only the Java Persistence part
    • JPA engines should be pluggable
    • JPA engines should be able to run outside EJB container
    • Hibernate implements the JPA
Advertisements
Tagged with: , ,
Posted in Hibernate, Java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: