Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search


< EclipseLink‎ | Examples‎ | JPA‎ | Migration‎ | OpenJPA

Differences between OpenJPA and EclipseLink: Column Type

There are a few differences between OpenJPA and EclipseLink in relation to column types.

Database Column Type

The columns added in the database tables created for each entity differ between OpenJPA and EclipseLink. When migrating from OpenJPA to EclipseLink, if a user wants to use existing tables created by OpenJPA, most of these differences will not be problematic since EclipseLink adapts to the existing column types when persisting new entities. The following table lists the field types that are created as a different column type in OpenJPA and EclipseLink.

Java Type OpenJPA EclipseLink
java.lang.Byte[], byte[]
BLOB(1048576) BLOB(64000)
java.lang.Boolean, boolean SMALLINT SMALLINT WITH DEFAULT 0
java.lang.Character CHAR(254) CHAR(1)
java.lang.Character[], char[] VARCHAR(254) CLOB(64000) LOGGED NOT COMPACT
java.lang.Float, float REAL DOUBLE
java.lang.String VARCHAR(254) VARCHAR(255)
java.math.BigDecimal DOUBLE DECIMAL(15,0)

CHAR(size) Return Value

Note: this is only applicable in some databases (ie. DB2)
In OpenJPA, when an entity defines a CHAR column with a size specified, persisted values shorter than the size specified will be returned with extra whitespace. However, in the same scenario, EclipseLink will return the original persisted value with no extra whitespace.
For example, for the following entity:

public class Student {
	@Column (columnDefinition="CHAR(20)")
	private String firstName;}

The following operations are executed:

Student student = new Student();
em.persist(student);System.out.println("Student name is (" + em.find(Student.class, id).getFirstName() + ")");

The output will be the following:

Student name is (John                )

Back to the top