简体   繁体   English

为什么Hibernate 5.2支持java.time.Instant,而JPA 2不支持?

[英]Why java.time.Instant is supported in Hibernate 5.2 but not in JPA 2?

Till now I have a understanding that JPA is a specification and Hibernate is ORM tool based on that specification and we can have different implementations of JPA. 到目前为止,我已经了解到JPA是一个规范,而Hibernate是基于该规范的ORM工具,我们可以使用JPA的不同实现。 But I could not understand how is it possible then that JPA 2 doesnot supports java.time.Instant but Hibernate 5.2x supports it. 但是我不明白JPA 2怎么可能不支持java.time.Instant,但是Hibernate 5.2x支持它。

I have read this question why-jpa-does-not-support-java-time-instant but it doesn't have proper answers and doesn't talks how hibernate is able to provide support for Instant being a JPA specific implementation. 我已经读过这个问题, 为什么-jpa-does-not-support-java-time-instant,但是它没有正确的答案,也没有谈论冬眠如何能够为Instant作为JPA特定实现提供支持。

JPA is just a specification - it's a set of interfaces to provide common API. JPA只是一个规范-它是提供通用API的一组接口。 It describes the access to relational database to help developers manage multiple dbms vendors. 它描述了对关系数据库的访问,以帮助开发人员管理多个dbms供应商。 There are multiple implementations of JPA, the reference is EclipseLink developed under Eclipse Public License. JPA有多种实现,参考是在Eclipse Public License下开发的EclipseLink。 In other words it's a standard, like SQL-92 or SQL:2006. 换句话说,这是一个标准,例如SQL-92或SQL:2006。 Databases that claim to support given standard can implement own features outside it to make data access easier. 声称支持给定标准的数据库可以在其外部实现自己的功能,从而简化数据访问。

In order to use JPA, we need an implementation. 为了使用JPA,我们需要一个实现。 Besides EclipseLink the most common are Hibernate, OpenJPA and DataNucleus. 除了EclipseLink,最常见的是Hibernate,OpenJPA和DataNucleus。 All of them support JPA 2.2. 它们都支持JPA 2.2。

They implement the JPA specification but also provide additional functionalities to overcome some of JPA's shortcomings. 它们不仅实现了JPA规范,而且还提供了其他功能来克服JPA的某些缺点。 Those functionalities are the main difference between implementations and make the code specific ie using, for example, Hibernate follows in code changes needed to be done when changing JPA specification. 这些功能是实现之间的主要区别,它们使代码特定化,例如,使用Hibernate遵循更改JPA规范时需要进行的代码更改。 Only when using JPA we can switch between implementations. 仅当使用JPA时,我们才可以在实现之间切换。 However I have never seen any project, that changed JPA vendor. 但是,我从未见过任何项目改变了JPA供应商。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么不向java.time.Instant添加周数? - Why is adding weeks to java.time.Instant not supported? 为什么 JPA 不支持 java.time.Instant? - Why JPA does not support java.time.Instant? Hibernate-在PostgreSQL中使用java.time.Instant - Hibernate - Using java.time.Instant with PostgreSQL 在JPA / Hibernate中对java.util.Date或java.time.Instant使用BIGINT列 - Use BIGINT column for java.util.Date or java.time.Instant in JPA/Hibernate Spring Boot 2.5.0 and InvalidDefinitionException: Java 8 日期/时间类型 `java.time.Instant` 默认不支持 - Spring Boot 2.5.0 and InvalidDefinitionException: Java 8 date/time type `java.time.Instant` not supported by default Spring Boot 2.7.6: Java 8 默认不支持日期/时间类型`java.time.Instant` - Spring Boot 2.7.6: Java 8 date/time type `java.time.Instant` not supported by default java.time.Instant(1.8)是线程安全的吗? - java.time.Instant (1.8) is thread safe? 将 Spring 从 2.4.1 升级到 2.6.1,默认不支持 `java.time.Instant` 错误 - Upgrading Spring Boot from 2.4.1 to 2.6.1, getting `java.time.Instant` not supported by default error 逗号无法通过java.time.Instant解析 - Comma fails parsing by java.time.Instant java.time.Instant 是如何计算纳秒的? - How are nanoseconds calculated in java.time.Instant?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM