Hibernate findByID implementation
I found the 开发者_如何学JAVAfollowing code on net for fetching a object from DB.Now what does lock indicates?? Whe does it lock?
public T findById(ID id, boolean lock) {
T entity;
if (lock) {
entity = (T) getSession().load(getPersistentClass(), id, LockMode.UPGRADE);
} else {
entity = (T) getSession().load(getPersistentClass(), id);
}
return entity;
}
It just uses the appropriate Hibernate LockMode. If you have a more specific question, it might be easier to answer.
精彩评论