I am wondering where the hibernate second level cache works as expected if I put a where clause in the hbm.xml class definition:
<hibernate-mapping>
<class name="com.clazzes.A" table="TABLE_A"
mutable="false" where="xyz=5" >
<cache usage="read-only"/>
<id name="id" />
...
Will hibernate still put the id as key into the cache, or do I have enable the query cache? E.g. when I then execute a HQL query like from A where id=2
that results in an SQL similar to select * from TABLE_A where id=2 and (xyz=5)
. If I execute this query twice, will it consider the second level cache, or will it nevertheless execute the SQL twice?