The Artima Developer Community
Sponsored Link

Java Community News
A Simple Introduction to Java Persistence

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

A Simple Introduction to Java Persistence Posted: May 25, 2006 10:42 AM
Reply to this message Reply
Summary
A key component of Java EE 5 is the Java Persistence API (JPA) that provides an object-relational mapping framework for enterprise applications. Although formally part of the EJB 3 spec, the JPA can be used stand-alone. In a recent java.net article, Josh Marinacci shows how to use JPA from a simple client-side application.
Advertisement

The Java Persistence API (JPA) occupies its own specification document within the broader EJB 3 spec. That separation highlights the fact that the JPA can be used outside a full EJB 3 container. Becase the JPA distills the best object-relational mapping and persistence ideas from a host of enterprise persistence frameworks, the JPA is now one of the most effective ways to access a relational database from even client-side Java applications.

Josh Marinacci's java.net article, An Introduction to Java Persistence for Client-Side Developers, provides an introductory JPA tutorial that those with little JPA familiarity will find especially helpful. The article assumes no Java EE knowledge—indeed, the JPA architecture itself delegates much of the heavy lifting to persistence providers, such as Hibernate, and reduces complexity by relying on sensible API defaults. In this example, only two JPA annotations, a single XML configuration file, and a few lines of extra code are used to persist a POJO from a client application. The annotations are as simple as the following:

@Entity
public class Person {
    @Id @GeneratedValue
    public Long id;
    public String first;
    public String middle;
    public String last;
}

While object-relational mapping is not appropriate for all applications, the JPA makes this technique a standard accessible to any Java application via an easy-to-use API. Do you envision yourself using the JPA even outside an EJB 3 container?

Topic: A Simple Introduction to Java Persistence Previous Topic   Next Topic Topic: Tangosol and DataSynapse Partner

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use