Jump to: navigation, search

Difference between revisions of "EclipseLink/UserGuide/JPA/Basic JPA Development/Mapping/Basic Mappings/Temporal"

m
m
Line 3: Line 3:
 
|toc=n
 
|toc=n
 
|eclipselink=y
 
|eclipselink=y
|eclipselinktype=JPA}}
+
|eclipselinktype=JPA
 +
|api=y
 +
|apis=
 +
* [http://www.eclipse.org/eclipselink/api/latest/javax/persistence/Temporal.html @Temporal]
 +
}}
  
 
=@Temporal=
 
=@Temporal=
Line 38: Line 42:
  
 
{{EclipseLink_Spec
 
{{EclipseLink_Spec
|section=Section 9.1.20 "Temporal Annotation"
+
|section=Section 11.1.47 "Temporal Annotation"
 
}}
 
}}
  

Revision as of 10:29, 2 May 2011

EclipseLink JPA

link="http://wiki.eclipse.org/EclipseLink"
EclipseLink
Website
Download
Community
Mailing ListForumsIRC
Bugzilla
Open
Help Wanted
Bug Day
Contribute
Browse Source

Elug api package icon.png Key API


@Temporal

Use the @Temporal annotation to specify the database type that EclipseLink persistence provider should persist for persistent fields or properties of type java.util.Date and java.util.Calendar only.

You can use this annotation with the @Basic annotation.

@Temporal Attributes
Attribute Description Default Required?
value Set this attribute to the TemporalType that corresponds to database type you want EclipseLink persistence provider to use:
  • DATE – equivalent of java.sql.Date
  • TIME – equivalent of java.time.Date
  • TIMESTAMP – equivalent of java.sql.Timestamp
Yes


The following example shows how to use this annotation to specify that EclipseLink persistence provider should persist java.util.Date field startDate as a DATE (java.sql.Date) database type.

Example: @Temporal Annotation
 @Entity
 public class Employee implements Serializable{
     ...
     @Temporal(DATE)
     protected java.util.Date startDate;
     ...
 }
Elug javaspec icon.gif

For more information, see Section 11.1.47 "Temporal Annotation" in the JPA Specification.


Eclipselink-logo.gif
Version: 2.2.0 DRAFT
Other versions...