在Hibernate中使用@Temporal注解是什么? [英] What is the use of the @Temporal annotation in Hibernate?
问题描述
Hibernate文档包含以下信息:
lock $ $
>在普通的Java API中,没有定义时间的时间精度。
在处理时态数据时,您可能想要描述数据库中
期望的精度。时间数据可以具有DATE,TIME或
TIMESTAMP精度(即实际日期,只有时间或两者)。使用
@Temporal注解来微调。
时间的时间精度是什么未定义
是什么意思?什么是时间
数据及其精度?它是如何微调的?
必须为持久性字段或类型的属性指定此注释.util.Date
和 java.util.Calendar
。它可能仅限于这些类型的字段或属性。
在普通的Java API中,时间的时间精度没有被定义,当处理时间数据时,可能需要描述数据库中的期望精度时态数据可以具有DATE,TIME或TIMESTAMP精度(即实际日期,只有时间或两者)使用 时间数据是与时间相关的数据,例如,在内容管理系统中,创建日期和最后一次数据可以在在某些情况下,时态数据需要精度,并且您希望将精确的日期/时间或两者都存储在数据库表中( 核心Java API中没有指定时间精度。 根据javadocs, 注解在查询 [以上各种来源收集的信息] The Hibernate Documentation has the information below for the In plain Java APIs, the temporal precision of time is not defined.
When dealing with temporal data you might want to describe the
expected precision in database. Temporal data can have DATE, TIME, or
TIMESTAMP precision (ie the actual date, only the time, or both). Use
the @Temporal annotation to fine tune that. What does This annotation must be specified for persistent fields or properties of type The In plain Java APIs, the temporal precision of time is not defined. When dealing with temporal data, you might want to describe the expected precision in database. Temporal data can have DATE, TIME, or TIMESTAMP precision (i.e., the actual date, only the time, or both). Use the The temporal data is the data related to time. For example, in a content management system, the creation-date and last-updated date of an article are temporal data. In some cases, temporal data needs precision and you want to store precise date/time or both ( The temporal precision is not specified in core Java APIs. As per javadocs, Annotation to declare an appropriate {@code TemporalType} on query
method parameters. Note that this annotation can only be used on
parameters of type {@link Date} with default [Information above collected from various sources] 这篇关于在Hibernate中使用@Temporal注解是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!基本
注释, Id
注释或 ElementCollection
注释(当元素集合值属于这种时间类型时)。
@Temporal $ c
TIMESTAMP
) 。
@Temporal
是一个在时间戳和 java.util之间来回转换的
。它还将 JPA
注释。日期时间戳
转换为时间。例如,在下面的代码片段中, @Temporal(TemporalType.DATE)
会删除时间值并仅保留日期。 em>
@Temporal(TemporalType.DATE)
private java.util.Date creationDate;
方法参数上声明适当的{TemporalType}。请注意,此注释只能用于带有默认 TemporalType.DATE
参数。
@Temporal
annotation:
temporal precision of time is not defined
mean? What is temporal
data and its precision? How does it fine tune?java.util.Date
and java.util.Calendar
. It may only be specified for fields or properties of these types.Temporal
annotation may be used in conjunction with the Basic
annotation, the Id
annotation, or the ElementCollection
annotation (when the element collection value is of such a temporal type. @Temporal
annotation to fine tune that.TIMESTAMP
) in database table.@Temporal
is a JPA
annotation that converts back and forth between timestamp and java.util.Date
. It also converts time-stamp
into time. For example, in the snippet below, @Temporal(TemporalType.DATE)
drops the time value and only preserves the date.@Temporal(TemporalType.DATE)
private java.util.Date creationDate;
TemporalType.DATE