这里发布的解决方案对我不起作用.但我已经使它成功:
@Cache @NamedQueries({@NamedQuery( name = "State.findAll", query = "SELECT s FROM State s", hints = { @QueryHint(name = QueryHints.QUERY_RESULTS_CACHE, value = HintValues.TRUE) } )})