fix hibernate+ehcache: miss for sql

If you are using an entity as a named parameter in a hibernate Query or Criteria which is cachable from ehcache then this entity needs to implement hashcode and equals using a business key. Otherwise the hibernate Query or Criteria may always “look different” to ehcache so it will be a constant cache miss.

DEBUG ( - query.FooBarCache: query.FooBarMemoryStore miss for sql: /* criteria query */ select as y0_ from foobars this_ where this_.state=?; parameters: LIVE; max rows: 1; transformer: org.hibernate.transform.PassThroughResultTransformer@294633f0
DEBUG ( - query.FooBar cache - Miss

Comments are closed.