Saturday, February 19, 2011

Enable JPA2 in Weblogic 10.3.4

WebLogic Server 10.3.4 Released - Key APIs of Java EE 6 and More

Running JPA 2.0 API on WebLogic 10.3

Enable JPA2 by adding JPA2 jar on PRE_CLASSPATH

# Set up BEA Home


Create JPA2 project in Eclipse Helios 3.6
Update Server Runtime to WLS 10.3.4

Create WLS 10.3.4 domain

Edit EJB project facets

Edit JPA facet

Create JPA entities from tables

Generated JPA class
package dave;

import javax.persistence.*;
import java.sql.Timestamp;
import java.math.BigDecimal;

* The persistent class for the BOOKS database table.
public class Book implements Serializable {
private static final long serialVersionUID = 1L;

@SequenceGenerator(name="BOOKS_ID_GENERATOR", sequenceName="ID_GEN")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BOOKS_ID_GENERATOR")
private long id;

private String author;

private BigDecimal counter;

private Timestamp insertTimestamp;

private String title;

public Book() {

public long getId() {

public void setId(long id) { = id;

public String getAuthor() {

public void setAuthor(String author) { = author;

public BigDecimal getCounter() {
return this.counter;

public void setCounter(BigDecimal counter) {
this.counter = counter;

public Timestamp getInsertTimestamp() {
return this.insertTimestamp;

public void setInsertTimestamp(Timestamp insertTimestamp) {
this.insertTimestamp = insertTimestamp;

public String getTitle() {
return this.title;

public void setTitle(String title) {
this.title = title;


Edit persistence.xml
<persistence version="2.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<persistence-unit name="example" transaction-type="JTA">
<shared-cache-mode>NONE</shared-cache-mode><!-- shared-cache-mode must come after any class definitions (usually SE only) - the JPA schema is ordered -->
<property name="" value="WebLogic_10"/>
<property name="" value="Oracle"/>
<property name="eclipselink.logging.level" value="FINEST"/>
<!-- new for -->
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
<!-- turn off DDL generation after the model is stable -->
<!-- property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
<!-- property name="eclipselink.ddl-generation.output-mode" value="database"/-->

1 comment:

  1. Even in the older weblogic versions 10.3.x there are ways to configure your JPA2.0 application using ORMS other then EclipseLink and the way suggested in my blog below doesn't even need to install any patch or add any new libraries in server class path, Please have a look