I'm currently using the "setcachable(true)" and natural identifiers, but hibernate still seems to be selecting from the database instead of the cache.
This is the output:
Code:
19:22:10,843 DEBUG SQL:346 -
select
this_.userID as userID8_0_,
this_.userName as userName8_0_,
this_.password as password8_0_,
this_.email as email8_0_,
this_.firstName as firstName8_0_,
this_.familyName as familyName8_0_,
this_.regDate as regDate8_0_,
this_.activeDate as activeDate8_0_,
this_.ip as ip8_0_,
this_.host as host8_0_,
this_.up as up8_0_,
this_.xp as xp8_0_,
this_.money as money8_0_,
this_.rankID as rankID8_0_,
this_.teamID as teamID8_0_
from
users this_
where
(
this_.userName=?
)
Hibernate:
select
this_.userID as userID8_0_,
this_.userName as userName8_0_,
this_.password as password8_0_,
this_.email as email8_0_,
this_.firstName as firstName8_0_,
this_.familyName as familyName8_0_,
this_.regDate as regDate8_0_,
this_.activeDate as activeDate8_0_,
this_.ip as ip8_0_,
this_.host as host8_0_,
this_.up as up8_0_,
this_.xp as xp8_0_,
this_.money as money8_0_,
this_.rankID as rankID8_0_,
this_.teamID as teamID8_0_
from
users this_
where
(
this_.userName=?
)
19:22:10,984 DEBUG ReadWriteCache:148 - Caching: objects.User#1
19:22:10,984 DEBUG EhCache:104 - key: objects.User#1
19:22:10,984 DEBUG EhCache:113 - Element for objects.User#1 is null
19:22:10,984 DEBUG ReadWriteCache:160 - Cached: objects.User#1
19:22:11,031 DEBUG SQL:346 -
select
this_.userID as userID8_0_,
this_.userName as userName8_0_,
this_.password as password8_0_,
this_.email as email8_0_,
this_.firstName as firstName8_0_,
this_.familyName as familyName8_0_,
this_.regDate as regDate8_0_,
this_.activeDate as activeDate8_0_,
this_.ip as ip8_0_,
this_.host as host8_0_,
this_.up as up8_0_,
this_.xp as xp8_0_,
this_.money as money8_0_,
this_.rankID as rankID8_0_,
this_.teamID as teamID8_0_
from
users this_
where
(
this_.userName=?
)
Hibernate:
select
this_.userID as userID8_0_,
this_.userName as userName8_0_,
this_.password as password8_0_,
this_.email as email8_0_,
this_.firstName as firstName8_0_,
this_.familyName as familyName8_0_,
this_.regDate as regDate8_0_,
this_.activeDate as activeDate8_0_,
this_.ip as ip8_0_,
this_.host as host8_0_,
this_.up as up8_0_,
this_.xp as xp8_0_,
this_.money as money8_0_,
this_.rankID as rankID8_0_,
this_.teamID as teamID8_0_
from
users this_
where
(
this_.userName=?
)
19:22:11,046 DEBUG ReadWriteCache:148 - Caching: objects.User#1
19:22:11,046 DEBUG EhCache:104 - key: objects.User#1
19:22:11,046 DEBUG ReadWriteCache:169 - Item was already cached: objects.User#1
Especially this part is interesting (somewhere between the two selects):
Code:
19:22:10,984 DEBUG ReadWriteCache:148 - Caching: objects.User#1
19:22:10,984 DEBUG EhCache:104 - key: objects.User#1
19:22:10,984 DEBUG EhCache:113 - Element for objects.User#1 is null
and then this (at the end)
Code:
19:22:11,046 DEBUG ReadWriteCache:148 - Caching: objects.User#1
19:22:11,046 DEBUG EhCache:104 - key: objects.User#1
19:22:11,046 DEBUG ReadWriteCache:169 - Item was already cached: