Value properties are mapped in JPA using the
javax.persistence.@Basic
annotation. In Naked
Objects' terms, this means properties whose return type is a built-in
value type: specifically primitives, String
,
java.util.Date
(and its subclasses),
java.sql.Timestamp
,
java.math.BigDecimal
,
java.math.BigInteger
. It is also possible to map
custom value types (that is, annotated with
org.nakedobjects.applib.annotation.@Value
); see
Chapter 6, Supporting Custom Value Types for more
details.
A property annotated with @Basic
will
correspond to a column in a database table. JPA will
map - to an appropriate SQL type - all of the
built-in value types supported by Naked Objects. The other types
supported by JPA -
java.util.Calendar
, and arrays of primitives and
wrappers, and enums - are not supported by Naked Objects as value
types.
JPA does also allow a property whose type is
serializable to be annotated with @Basic
.
However, it will be stored in the database as a blob. This is therefore
not a recommended approach; better is to implement a custom value
type.
Properties of type java.util.Date
can be
annotated using @javax.persistence.Temporal
. This
provides a hint as to the SQL type to use: DATE, TIME or
TIMESTAMP.