JPA - Column Mapping

Card Puncher Data Processing

About

This article is about the mapping of a column without relationship

Every JPA entity must have a primary key.

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)

Support

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

Just add a @temporal type:

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

Documentation / Reference







Share this page:
Follow us:
Task Runner