读书人

试工Hibernate二级缓存Ehcache

发布时间: 2012-10-30 16:13:36 作者: rapoo

试用Hibernate二级缓存Ehcache

? Hibernatesupports several third-party caching services.?After some research, the team has concluded that Ehcache would besuitable for our requirements, namely the caching of frequently-accessed,read-only tables.

?

Ehcache Evaluation

?

Hibernate 3.3.2 GA

  • Ehcache 1.2.3 (an optional JAR bundled with Hibernate 3.3.2)
  • Hibernate Annotations 3.4.0 GA


    Configuration

    Hibernate is configured to enable caching.

  • An ehcache.xml file is created and placed on the classpath.
  • Model classes are updated to add @Cache annotations to entities and associations.
  • Hibernate Query instances are explicitly designated as cacheable before execution.

    ?

    ?3,model example,Questionnaire.java

    ?4,Query cache,??? Old:
    Depth Optimization??? Old:
    private List<Response> findRespose(Long pageInQuestionId, Set aSetResponses,String responseValue) {List<Response> lResponses = new ArrayList();Iterator listResponses = aSetResponses.iterator();while (listResponses.hasNext()) {Response lResponse = (Response) listResponses.next();if (lResponse.getQuestion().getId() == pageInQuestionId && lResponse.getValue().equals(responseValue)){lResponses.add(lResponse);} } // Response could not be found:return lResponses;}
    ??If any question I will put in this thread.

  • 读书人网 >软件架构设计

    热点推荐