开发者

Hibernate findByID implementation

开发者 https://www.devze.com 2023-03-22 18:30 出处:网络
I found the 开发者_如何学JAVAfollowing code on net for fetching a object from DB.Now what does lock indicates??

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消