Temporal types are the set of time-based types that can be used in persistent state mappings. The list
of supported temporal types includes the three java.sqltypes java.sql.Date, java.sql.Time, and
java.sql.Timestamp, and it includes the two java.utiltypes java.util.Dateand java.util.Calendar.
The java.sqltypes are completely hassle-free. They act just like any other simple mapping type
and do not need any special consideration. The two java.utiltypes need additional metadata,
however, to indicate which of the JDBC java.sqltypes to use when communicating with the JDBC
driver. This is done by annotating them with the @Temporalannotation and specifying the JDBC type as
a value of the TemporalTypeenumerated type. There are three enumerated values of DATE, TIME, and
TIMESTAMPto represent each of the java.sqltypes.
Listing 4-12 shows how java.util.Dateand java.util.Calendarcan be mapped to date columns in
the database.
đang được dịch, vui lòng đợi..
