JPA2.0支持自定义用户类型和二级缓存 [英] JPA2.0 support of custom user-types and second level cache

查看:157
本文介绍了JPA2.0支持自定义用户类型和二级缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图决定是否从 Hibernate 全部转换为使用 JPA2.0 以及因此是提供者可移植的。

1.Does JPA2.0 支持自定义用户类型?

2.I'm on主要考虑将 Terracotta 作为二级缓存来实现 Hibernate 的边界。我可以想象,但我实际上并不知道, JPA2.0 也为二级缓存提供者定义了一个规范。如果我是对的, Terracotta 是否实现它? (如果有人可以指点我开始使用 Terracotta JPA 我很感激它)。



在此先感谢,

Ittai

解决方案


JPA2.0是否支持自定义用户类型?


没有超出 @Embedded @Embeddable (已在JPA 1.0中)。根据您的需求的复杂程度,他们可能会完成这项工作)。


我会想象,但我实际上不知道, JPA2.0还为二级缓存提供者定义了一个规范。

JPA 2.0在 EntityManager 上定义了访问二级缓存的方法,由持久性提供者维护,一个 Cacheable 注释,以及其他一些事情。但是,在您的JPA提供程序上插入缓存的方式是特定于提供程序的。所以不,JPA没有为L2缓存提供者定义规范。如果您希望将Terracota作为使用Hibernate的L2缓存提供程序作为JPA 2.0实现,请参阅Hibernate集成文档。



参考




  • JPA 2.0规范


    • 第3.7节缓存
    • 第7.10节缓存接口
    • 第11.1.7节缓存注释


    I'm trying to decide whether to switch from having Hibernate sprinkled all over to using JPA2.0 and thus be provider portable.
    1.Does JPA2.0 support custom user-types?
    2.I'm on the verge of implementing Terracotta as a second-level cache to Hibernate with its clustering abilities mainly in mind. I would imagine, but I don't actually know, that JPA2.0 also defines a spec for second-level cache providers. If I'm right, does Terracotta implement it? (If someone could point me to a getting started with Terracotta and JPA I'd appreciate it).

    Thanks in advance,
    Ittai

    解决方案

    Does JPA2.0 support custom user-types?

    Nothing beyond @Embedded and @Embeddable (already in JPA 1.0). Depending on the complexity of your needs, they might do the job).

    I would imagine, but I don't actually know, that JPA2.0 also defines a spec for second-level cache providers.

    JPA 2.0 defines methods on the EntityManager to access the second level cache that is maintained by the persistence provider, a Cacheable annotation, some other things. But the way to plug a cache on your JPA provider is provider specific. So no, JPA doesn't define a spec for L2 cache providers. And if you want to use Terracota as the L2 cache provider with Hibernate as JPA 2.0 implementation, look at the Hibernate integration documentation.

    References

    • JPA 2.0 specification
      • Section 3.7 "Caching"
      • Section 7.10 "Cache Interface"
      • Section 11.1.7 "Cacheable Annotation"

    这篇关于JPA2.0支持自定义用户类型和二级缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆