Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA2.0 support of custom user-types and second level cache

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

like image 213
Ittai Avatar asked Sep 02 '10 14:09

Ittai


1 Answers

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"
like image 149
Pascal Thivent Avatar answered Sep 28 '22 04:09

Pascal Thivent