Announcement Announcement Module
Collapse
No announcement yet.
Hibernate Lock with Criteria Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate Lock with Criteria

    Hi. I have a question. I'm relatively new to Hibernate and Spring, so maybe I'm missing something.
    When I do something like this inside a Transaction with HibernateTemplate:

    Code:
    MyClass obj=(MyClass)hibernateTemplate.get(MyClass.class,pk)
    I obtain a shared read lock on the row corresponding to the object obj (LockMode.READ) until the transaction is commited.

    Yet, when I do something like this inside a transaction:

    Code:
    DetachedCriteria criteria = DetachedCriteria.forClass(MyClass.class);
    criteria.add(Restrictions.like("myProp", prop+"%"));
    List<MyClass> subs= hibernateTemplate.findByCriteria(criteria);
    I do NOT obtain a shared lock on the row corresponding to the objects contained in the list. Is this behaviour correct or there is something wrong with my test or my database?
    I'm using MySql ndbcluster as datastore.

    Thank you
    Davide

  • #2
    There's a discussion of locking in the reference manual.
    http://www.hibernate.org/hib_docs/v3...ctions-locking
    Last edited by karldmoore; Aug 29th, 2007, 10:38 AM.

    Comment

    Working...
    X