程序包 org.hibernate

枚举 LockMode

  • 所有已实现的接口:
    Serializable, Comparable<LockMode>

    public enum LockMode
    extends Enum<LockMode>
    Instances represent a lock mode for a row of a relational database table. It is not intended that users spend much time worrying about locking since Hibernate usually obtains exactly the right lock level automatically. Some "advanced" users may wish to explicitly specify lock levels.
    作者:
    Gavin King
    另请参阅:
    Session.lock(Object, LockMode)
    • 枚举常量详细资料

      • NONE

        public static final LockMode NONE
        No lock required. If an object is requested with this lock mode, a READ lock will be obtained if it is necessary to actually read the state from the database, rather than pull it from a cache.

        This is the "default" lock mode.
      • READ

        public static final LockMode READ
        A shared lock. Objects in this lock mode were read from the database in the current transaction, rather than being pulled from a cache.
      • UPGRADE

        @Deprecated
        public static final LockMode UPGRADE
        已过时。
        instead use PESSIMISTIC_WRITE
        An upgrade lock. Objects loaded in this lock mode are materialized using an SQL select ... for update.
      • UPGRADE_NOWAIT

        public static final LockMode UPGRADE_NOWAIT
        Attempt to obtain an upgrade lock, using an Oracle-style select for update nowait. The semantics of this lock mode, once obtained, are the same as UPGRADE.
      • UPGRADE_SKIPLOCKED

        public static final LockMode UPGRADE_SKIPLOCKED
        Attempt to obtain an upgrade lock, using an Oracle-style select for update skip locked. The semantics of this lock mode, once obtained, are the same as UPGRADE.
      • WRITE

        public static final LockMode WRITE
        A WRITE lock is obtained when an object is updated or inserted. This lock mode is for internal use only and is not a valid mode for load() or lock() (both of which throw exceptions if WRITE is specified).
      • FORCE

        @Deprecated
        public static final LockMode FORCE
        已过时。
        instead use PESSIMISTIC_FORCE_INCREMENT
        Similar to UPGRADE except that, for versioned entities, it results in a forced version increment.
      • OPTIMISTIC

        public static final LockMode OPTIMISTIC
        Optimistically assume that transaction will not experience contention for entities. The entity version will be verified near the transaction end.
      • OPTIMISTIC_FORCE_INCREMENT

        public static final LockMode OPTIMISTIC_FORCE_INCREMENT
        Optimistically assume that transaction will not experience contention for entities. The entity version will be verified and incremented near the transaction end.
      • PESSIMISTIC_READ

        public static final LockMode PESSIMISTIC_READ
        Implemented as PESSIMISTIC_WRITE. TODO: introduce separate support for PESSIMISTIC_READ
      • PESSIMISTIC_WRITE

        public static final LockMode PESSIMISTIC_WRITE
        Transaction will obtain a database lock immediately. TODO: add PESSIMISTIC_WRITE_NOWAIT
      • PESSIMISTIC_FORCE_INCREMENT

        public static final LockMode PESSIMISTIC_FORCE_INCREMENT
        Transaction will immediately increment the entity version.
    • 方法详细资料

      • values

        public static LockMode[] values()
        按照声明该枚举类型的常量的顺序, 返回 包含这些常量的数组。该方法可用于迭代 常量, 如下所示:
        for (LockMode c : LockMode.values())
            System.out.println(c);
        
        返回:
        按照声明该枚举类型的常量的顺序返回的包含这些常量的数组
      • valueOf

        public static LockMode valueOf​(String name)
        返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)
        参数:
        name - 要返回的枚举常量的名称。
        返回:
        返回带有指定名称的枚举常量
        抛出:
        IllegalArgumentException - 如果该枚举类型没有带有指定名称的常量
        NullPointerException - 如果参数为空值
      • greaterThan

        public boolean greaterThan​(LockMode mode)
        Check if this lock mode is more restrictive than the given lock mode.
        参数:
        mode - LockMode to check
        返回:
        true if this lock mode is more restrictive than given lock mode
      • lessThan

        public boolean lessThan​(LockMode mode)
        Check if this lock mode is less restrictive than the given lock mode.
        参数:
        mode - LockMode to check
        返回:
        true if this lock mode is less restrictive than given lock mode
      • toExternalForm

        public String toExternalForm()
      • fromExternalForm

        public static LockMode fromExternalForm​(String externalForm)