J4Fry JSF JPA bridge

Characteristics

Attribute Value
Project name J4Fry JSF JPA bridge
Prerequisites JDK >= 5.0, JSF 1.1 or 1.2 compliant implementation, Hibernate, PostgreSQL
CVS module Lookups
Responsible developer Ganesh Jung

About

This is a small piece of code that takes all thinking about transaction handling from the developers shoulders. It simply opens a transaction as soon as a JSF request comes in and it closes the transaction when the response is rendered. For non-faces requests it opens a transaction before the render response phase so that an eventual onLoad action (see onLoad tag) can use an open transaction. The whole thing is done with JSF phase listeners so that adding the jar to your project is enough to activate the process. The code relies on the java persistence api (JPA) for transaction handling thus bridging between JSF and JPA.

Installation

Name your JPA persistence-unit to "j4fry". Drop this jar into your classpath:

j4fry-components-1.2.jar

Usage

Use this solution in web application that don't provide a transaction handling environment to get a lightweight universal JSF JPA bridge.

The bridge provides the call org.j4fry.common.database.TransactionManager. Each time you need an entity manager in your application to access the database call TransactionManager.getInstance().getEntityManager().