JPA - Column Mapping

1 - About

This article is about the mapping of a column without relationship

Every JPA entity must have a primary key.

3 - Basic

A basic attribute is one where the attribute class (datatype) is a simple type such as:

Java type Database type
String (char, char[]) VARCHAR (CHAR, VARCHAR2, CLOB, TEXT)
Number (BigDecimal, BigInteger, Integer, Double, Long, Float, Short, Byte) NUMERIC (NUMBER, INT, LONG, FLOAT, DOUBLE)
int, long, float, double, short, byte NUMERIC (NUMBER, INT, LONG, FLOAT, DOUBLE)
byte[] VARBINARY (BINARY, BLOB)
boolean (Boolean) BOOLEAN (BIT, SMALLINT, INT, NUMBER)
java.util.Date TIMESTAMP (DATE, DATETIME)
java.sql.Date DATE (TIMESTAMP, DATETIME)
java.sql.Time TIME (TIMESTAMP, DATETIME)
java.sql.Timestamp TIMESTAMP (DATETIME, DATE)
java.util.Calendar TIMESTAMP (DATETIME, DATE)
java.lang.Enum NUMERIC (VARCHAR, CHAR)
java.util.Serializable VARBINARY (BINARY, BLOB)

4 - Support

4.1 - The attribute from the entity class does not specify a temporal type

Just add a @temporal type:

@Basic()
@Temporal(TemporalType.TIMESTAMP)
private Calendar lastModified;

5 - Documentation / Reference

jpa/column.txt ยท Last modified: 2017/02/12 21:06 by gerardnico