JPA Annotations – @Temporal
来源:互联网 发布:gta5捏脸数据女生初音 编辑:程序博客网 时间:2024/05/22 04:46
Temporal annotation in JPA implementation can only be used with the fields and property get methods. Also, this annotation can be specified for the persistent fields or properties java.util.Data or java.util.Calendar. This annotation is available since the release of JPA 1.0. @Temporal solves the one of the major issue of converting the date and time values from Java object to compatible database type and retrieving back to the application. When Java class declares the fields java.sql.Date or java.sql.Time, then it is compatible with the database types and will not have any issues. But, when we are using the java.util.Date or java.util.Calendar, then we have to specify Temporal types to map the appropriate database types when persisting to the database.
@Temporal Syntax
It can be declared with the following syntax,
1
@Temporal
(value)</span>
The valid values are,
- TemporalType.DATE
- TemporalType.TIME
- TemporalType.TIMESTAMP
@Temporal Example
For example,
- See more at: http://www.javabeat.net/jpa-annotations-temporal/#sthash.d7vveKsL.dpuf
@Temporal
(TemporalType.DATE)
2
@Column
(name =
"DATE_COL"
)
3
private
java.util.Date dateCol;
The corresponding XML declaration is:
1
<entity class="Country">
2
<attributes>
3
<basic name="submitDate">
4
<temporal>DATE</temporal>
5
</basic>
6
</attributes>
7
</entity>
It is equivalent of
- DATE – equivalent of java.sql.Date
- TIME – equivalent of java.sql.Time
- TIMESTAMP – equivalent of java.sql.Timestamp
引用自:http://www.javabeat.net/jpa-annotations-temporal/
- JPA Annotations – @Temporal
- jpa @Temporal
- hibernate jpa注解 @Temporal
- hibernate jpa 注解 @Temporal
- hibernate jpa注解 @Temporal
- hibernate jpa 注解 @Temporal()
- JPA 映射时间(Temporal)类型@Temporal
- JPA 映射时间(Temporal)类型@Temporal
- JPA 映射时间(Temporal)类型@Temporal
- JPA 映射时间(Temporal)类型@Temporal
- @Temporal JPA 映射时间(Temporal)类型
- @Temporal JPA 映射时间(Temporal)类型
- EJB3/JPA Annotations 学习
- hibernate-annotations jpa
- jpa常用annotations
- 8. JPA @Temporal注解详解
- hibernate-annotations jpa级联操作
- hibernate jpa 注解 @Temporal(TemporalType.DATE)
- 如何学好C语言
- 浅谈Java中的hashcode方法
- 关于如何在vector中的某些元素(这些元素均是相同的值)之前插入一个特定的值
- 折半查找,插入
- 同步和异步的区别(转)
- JPA Annotations – @Temporal
- discuz数据库迁移,改密码后,相关配置文件修改
- 设备状态对Activity生命周期的影响
- leetcode 第九题 Palindrome Number(java)
- @autoreleasepool 创建自动释放连接池(内存管理)
- IOS开发偏门技巧
- 视频质量估计的通用参数模型
- iOS8开发~UI布局(二)storyboard中autolayout和size class的使用详解
- x.509证书结构与例子