I want to be able to check whether a session contains an entity of a given class/identifier. I can't see a way to do this at the moment.
contains()
takes an entity object not class + keyget()
queries the database if the entity is not present which I don't want to doload()
never returns null as a proxy is always created so I can't use this methodIs it possible to do the above with no side-effects/queries to DB?
This works:
public boolean isIdLoaded(Serializable id)
{
for (Object key : getSession().getStatistics().getEntityKeys())
{
if (((EntityKey) key).getIdentifier().equals(id))
{
return true;
}
}
return false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With