The reason I use the SessionBean is exactly for what you mention. That is, I don't want to write the transaction begin/commit within try/catch/finally as I like to think that session beans are used to encapsulate my business logic within transaction boundaries. Is this approach correct?

Please note that I get the "openjpa.jdbc.Schema - Existing column "CODE" on table "APP.PROMOTION" is incompatible with the same column in the given schema definition" error message for pretty much every field in my tables (entities). I just pasted one of them in my previous note to keep the message short.

My orm.xml file is pretty much empty:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="" xmlns:xsi="" xsi:schemaLocation="" version="1.0">

My persistence.xml file is as follows (I've tried switching from transaction-type={JTA | RESOURCE_LOCAL} but from reading some articles, it sounds like I should be using the latter option, is this correct?)

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<persistence-unit name="MyDataAppJPA" transaction-type="RESOURCE_LOCAL">

<!-- exclude-unlisted-classes>true</exclude-unlisted-classes -->

<property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="openjpa.ConnectionURL" value="jdbc:derby://localhost:1527/testdb"/>
<!-- property name="openjpa.TransactionMode" value="managed"/ -->
<property name="openjpa.ConnectionFactoryMode" value="managed"/>
<property name="openjpa.jdbc.DBDictionary" value="derby"/>
<property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.DerbyDictionary"/>
<property name="openjpa.jdbc.Schema" value="APP"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction='add',ForeignKeys=true)"/>
<!-- property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=false)"/ -->
<property name="openjpa.Sequence" value="table(Table=OPENJPASEQ, Increment=100)"/>
<!-- property name="openjpa.Log" value="DefaultLevel=TRACE"/ -->

Here is my SQL table definition:

CREATE TABLE Promotion (
product_id INTEGER NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
code CHAR(8),
message VARCHAR(1024),
broadcast CHAR(5)

Here is the Promotion class:


import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;

public class Promotion implements Serializable {
@Column(name="PRODUCT_ID", insertable=false, updatable=false)
private int productId;

private Date startDate;

private Date endDate;

private String code;
private short discount;
private String message;
private String broadcast;

private static final long serialVersionUID = 1L;

public Promotion() {

// getters and setters follow

Benjamin S. Vera-Tudela
SWG Middleware Strategy
Ph: (512)-286-9073 T/L 363-9073

Inactive hide details for Craig L Russell ---06/12/2009 05:11:56 PM---Hi Benjamin, If you access OpenJPA from your servlet direCraig L Russell ---06/12/2009 05:11:56 PM---Hi Benjamin, If you access OpenJPA from your servlet directly, then you use the EntityTransaction to begin and commit transacti


Craig L Russell <Craig.Russell@Sun.COM>



06/12/2009 05:11 PM


Re: Questions about OpenJPA issues

Hi Benjamin,

If you access OpenJPA from your servlet directly, then you use the EntityTransaction to begin and commit transactions. But if you delegate to a SessionBean, the bean's transaction properties begin and commit transactions without your writing any code.

With regard to the schema mismatch, without seeing the orm metadata and the table definition it's hard to figure out where the problem is. The apache servers remove attachments from emails. Can you try pasting the text of the orm definition and the class definition for the Promotion class into the message?



On Jun 11, 2009, at 3:06 PM, Benjamin S Vera-Tudela wrote:

Craig L Russell
Architect, Sun Java Enterprise System
408 276-5638
P.S. A good JDO? O, Gasp!