TechnoBuzz

A Techno Blog, mainly about Java

JPA Examples

jpa spec jsr 317

open jpa manual

In an applicationserver, EntityManager instances are typically injected, rendering the EntityManagerFactory unnecessary.

javax.persistence:

  • Persistence : contains static helper methods to obtain EntityManagerFactory
    instances in a vendor-neutral fashion.
  • EntityManagerFactory: is a factory for Entity-Manager
  • EntityManager: is the primary JPA interface used by applications.Each EntityManager manages a set of persistent objects, and has APIs to insert new objects and delete existing ones. EntityManagers also act as factories for Query instances.
  • Entity: persistent objects that represent datastore records.
  • Query: Query interface is implemented by each JPA vendor to find persistent objects that
    meet certain criteria. JPA standardizes support for queries using both the Java Persistence Query Language (JPQL) and the Structured Query Language (SQL). You obtain Query instances from an EntityManager.

JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to concurrently modify the same record, it throws an exception to the transaction attempting to commit last. This prevents overwriting the previous commit with stale data.

private int version;

JPA introduces another form of object identity, called entity identity or persistent identity. Entity identity tests whether two persistent objects represent the same state in the datastore.

Advertisements

May 11, 2008 - Posted by | Hibernate & ORM, J2EE

No comments yet.

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: