Q:

How do I create a JPA second-level cache for use with an entity's secondary key?

I'd like to create a JPA second-level cache for use with an entity's secondary key. As an example let's use State (as in California) and I'd like to use it's abbreviation ("CA") as the cache key. How do I set this up?
I'm using Infinispan with Wildfly 8. Do I have to work with Infinispan directly? If so, how do I define the cache (in the persistence.xml ?) and how do I access it in my code?

A:

You may want to look at @NaturalId.
It seems to utilize the second-level cache as well.

