Package org.hibernate

Examples of org.hibernate.LockOptions


  protected String buildSelectQuery(Dialect dialect) {
    final String alias = "tbl";
    final String query = "select " + StringHelper.qualify( alias, valueColumnName ) +
        " from " + tableName + ' ' + alias +
        " where " + StringHelper.qualify( alias, segmentColumnName ) + "=?";
    final LockOptions lockOptions = new LockOptions( LockMode.PESSIMISTIC_WRITE );
    lockOptions.setAliasSpecificLockMode( alias, LockMode.PESSIMISTIC_WRITE );
    final Map updateTargetColumnsMap = Collections.singletonMap( alias, new String[] { valueColumnName } );
    return dialect.applyLocksToSql( query, lockOptions, updateTargetColumnsMap );
  }
View Full Code Here


      Map properties) {
    this.entityManagerFactory = entityManagerFactory;
    this.persistenceContextType = type;
    this.transactionType = transactionType;

    this.lockOptions = new LockOptions();
    this.properties = new HashMap<String, Object>();
    if ( properties != null ) {
      for ( String key : entityManagerSpecificProperties ) {
        if ( properties.containsKey( key ) ) {
          this.properties.put( key, properties.get( key ) );
View Full Code Here

  }

  public <A> A find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) {
    CacheMode previousCacheMode = getSession().getCacheMode();
    CacheMode cacheMode = determineAppropriateLocalCacheMode( properties );
    LockOptions lockOptions = null;
    try {
      getSession().setCacheMode( cacheMode );
      if ( lockModeType != null ) {
        return ( A ) getSession().get(
            entityClass, ( Serializable ) primaryKey,
View Full Code Here

  public void refresh(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    checkTransactionNeeded();
    CacheMode previousCacheMode = getSession().getCacheMode();
    CacheMode localCacheMode = determineAppropriateLocalCacheMode( properties );
    LockOptions lockOptions = null;
    try {
      getSession().setCacheMode( localCacheMode );
      if ( !getSession().contains( entity ) ) {
        throw new IllegalArgumentException( "Entity not managed" );
      }
View Full Code Here

  public void lock(Object entity, LockModeType lockMode) {
    lock( entity, lockMode, null );
  }

  public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    LockOptions lockOptions = null;
    try {
      if ( !isTransactionInProgress() ) {
        throw new TransactionRequiredException( "no transaction is in progress" );
      }
      if ( !contains( entity ) ) {
View Full Code Here

      throw convert( he, lockOptions );
    }
  }

  public LockOptions getLockRequest(LockModeType lockModeType, Map<String, Object> properties) {
    LockOptions lockOptions = new LockOptions();
    LockOptions.copy( this.lockOptions, lockOptions );
    lockOptions.setLockMode( getLockMode( lockModeType ) );
    if ( properties != null ) {
      setLockOptions( properties, lockOptions );
    }
    return lockOptions;
  }
View Full Code Here

      Map properties) {
    this.entityManagerFactory = entityManagerFactory;
    this.persistenceContextType = type;
    this.transactionType = transactionType;

    this.lockOptions = new LockOptions();
    this.properties = new HashMap<String, Object>();
    if ( properties != null ) {
      for ( String key : entityManagerSpecificProperties ) {
        if ( properties.containsKey( key ) ) {
          this.properties.put( key, properties.get( key ) );
View Full Code Here

  }

  public <A> A find(Class<A> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) {
    CacheMode previousCacheMode = getSession().getCacheMode();
    CacheMode cacheMode = determineAppropriateLocalCacheMode( properties );
    LockOptions lockOptions = null;
    try {
      getSession().setCacheMode( cacheMode );
      if ( lockModeType != null ) {
        lockOptions = getLockRequest( lockModeType, properties );
        return ( A ) getSession().get(
View Full Code Here

  public void refresh(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    checkTransactionNeeded();
    CacheMode previousCacheMode = getSession().getCacheMode();
    CacheMode localCacheMode = determineAppropriateLocalCacheMode( properties );
    LockOptions lockOptions = null;
    try {
      getSession().setCacheMode( localCacheMode );
      if ( !getSession().contains( entity ) ) {
        throw new IllegalArgumentException( "Entity not managed" );
      }
View Full Code Here

  public void lock(Object entity, LockModeType lockMode) {
    lock( entity, lockMode, null );
  }

  public void lock(Object entity, LockModeType lockModeType, Map<String, Object> properties) {
    LockOptions lockOptions = null;
    if ( !isTransactionInProgress() ) {
      throw new TransactionRequiredException( "no transaction is in progress" );
    }

    try {
View Full Code Here

TOP

Related Classes of org.hibernate.LockOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.