Examples of Lockable


Examples of org.hibernate.persister.entity.Lockable

    final Map keyColumnNames = dialect.forUpdateOfColumns() ? new HashMap() : null;
    final String[] drivingSqlAliases = getAliases();
    for ( int i = 0; i < drivingSqlAliases.length; i++ ) {
      final LockMode lockMode = lockOptions.getAliasSpecificLockMode( drivingSqlAliases[i] );
      if ( lockMode != null ) {
        final Lockable drivingPersister = ( Lockable ) getEntityPersisters()[i];
        final String rootSqlAlias = drivingPersister.getRootTableAlias( drivingSqlAliases[i] );
        locks.setAliasSpecificLockMode( rootSqlAlias, lockMode );
        if ( keyColumnNames != null ) {
          keyColumnNames.put( rootSqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
        }
      }
    }
    return dialect.applyLocksToSql( sqlSelectString, locks, keyColumnNames );
  }
View Full Code Here

Examples of org.hibernate.persister.entity.Lockable

      // (necessarily) the table against which we want to apply locks.  Mainly,
      // the exception case here is joined-subclass hierarchies where we instead
      // want to apply the lock against the root table (for all other strategies,
      // it just happens that driving and root are the same).
      final QueryNode select = ( QueryNode ) queryTranslator.getSqlAST();
      final Lockable drivingPersister = ( Lockable ) select.getFromClause()
          .findFromElementByUserOrSqlAlias( userAlias, drivingSqlAlias )
          .getQueryable();
      final String sqlAlias = drivingPersister.getRootTableAlias( drivingSqlAlias );

      final LockMode effectiveLockMode = lockOptions.getEffectiveLockMode( userAlias );
      locks.setAliasSpecificLockMode( sqlAlias, effectiveLockMode );

      if ( keyColumnNames != null ) {
        keyColumnNames.put( sqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
      }
    }

    // apply the collected locks and columns
    return dialect.applyLocksToSql( sql, locks, keyColumnNames );
View Full Code Here

Examples of org.hibernate.persister.entity.Lockable

      // (necessarily) the table against which we want to apply locks.  Mainly,
      // the exception case here is joined-subclass hierarchies where we instead
      // want to apply the lock against the root table (for all other strategies,
      // it just happens that driving and root are the same).
      final QueryNode select = ( QueryNode ) queryTranslator.getSqlAST();
      final Lockable drivingPersister = ( Lockable ) select.getFromClause().getFromElement( userAlias ).getQueryable();
      final String sqlAlias = drivingPersister.getRootTableAlias( drivingSqlAlias );
      aliasedLockModes.put( sqlAlias, me.getValue() );
      if ( keyColumnNames != null ) {
        keyColumnNames.put( sqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
      }
    }
    return dialect.applyLocksToSql( sql, aliasedLockModes, keyColumnNames );
  }
View Full Code Here

Examples of org.hibernate.persister.entity.Lockable

    final Map keyColumnNames = dialect.forUpdateOfColumns() ? new HashMap() : null;
    final String[] drivingSqlAliases = getAliases();
    for ( int i = 0; i < drivingSqlAliases.length; i++ ) {
      final LockMode lockMode = lockOptions.getAliasSpecificLockMode( drivingSqlAliases[i] );
      if ( lockMode != null ) {
        final Lockable drivingPersister = ( Lockable ) getEntityPersisters()[i];
        final String rootSqlAlias = drivingPersister.getRootTableAlias( drivingSqlAliases[i] );
        locks.setAliasSpecificLockMode( rootSqlAlias, lockMode );
        if ( keyColumnNames != null ) {
          keyColumnNames.put( rootSqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
        }
      }
    }
    return dialect.applyLocksToSql( sqlSelectString, locks, keyColumnNames );
  }
View Full Code Here

Examples of org.hibernate.persister.entity.Lockable

      // (necessarily) the table against which we want to apply locks.  Mainly,
      // the exception case here is joined-subclass hierarchies where we instead
      // want to apply the lock against the root table (for all other strategies,
      // it just happens that driving and root are the same).
      final QueryNode select = ( QueryNode ) queryTranslator.getSqlAST();
      final Lockable drivingPersister = ( Lockable ) select.getFromClause()
          .findFromElementByUserOrSqlAlias( userAlias, drivingSqlAlias )
          .getQueryable();
      final String sqlAlias = drivingPersister.getRootTableAlias( drivingSqlAlias );

      final LockMode effectiveLockMode = lockOptions.getEffectiveLockMode( userAlias );
      locks.setAliasSpecificLockMode( sqlAlias, effectiveLockMode );

      if ( keyColumnNames != null ) {
        keyColumnNames.put( sqlAlias, drivingPersister.getRootTableIdentifierColumnNames() );
      }
    }

    // apply the collected locks and columns
    return dialect.applyLocksToSql( sql, locks, keyColumnNames );
View Full Code Here

Examples of org.springframework.aop.framework.Lockable

    assertEquals("introductionUsingJdk", tb.getName());

    ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk");

    // Check two per-instance mixins were distinct
    Lockable lockable1 = (Lockable) tb;
    Lockable lockable2 = (Lockable) tb2;
    assertFalse(lockable1.locked());
    assertFalse(lockable2.locked());
    tb.setAge(65);
    assertEquals(65, tb.getAge());
    lockable1.lock();
    assertTrue(lockable1.locked());
    // Shouldn't affect second
    assertFalse(lockable2.locked());
    // Can still mod second object
    tb2.setAge(12);
    // But can't mod first
    try {
      tb.setAge(6);
View Full Code Here

Examples of org.springframework.aop.framework.Lockable

    assertEquals(3, nop.getCount());   
 
    ITestBean tb2 = (ITestBean) beanFactory.getBean("second-introductionUsingJdk");
     
    // Check two per-instance mixins were distinct
    Lockable lockable1 = (Lockable) tb;
    Lockable lockable2 = (Lockable) tb2;
    assertFalse(lockable1.locked());
    assertFalse(lockable2.locked());
    tb.setAge(65);
    assertEquals(65, tb.getAge());
    lockable1.lock();
    assertTrue(lockable1.locked());
    // Shouldn't affect second
    assertFalse(lockable2.locked());
    // Can still mod second object
    tb2.setAge(12);
    // But can't mod first
    try {
      tb.setAge(6);
View Full Code Here

Examples of org.springframework.aop.framework.Lockable

  // on the introduction, in which case this would not be a problem.
  public void testLockingWorks() {
    Object introductionObject = applicationContext.getBean("introduction");
    assertFalse("Introduction should not be proxied", AopUtils.isAopProxy(introductionObject));

    Lockable lockable = (Lockable) testBeanProxy;
    assertFalse(lockable.locked());

    // Invoke a non-advised method
    testBeanProxy.getAge();

    testBeanProxy.setName("");
    lockable.lock();
    try {
      testBeanProxy.setName(" ");
      fail("Should be locked");
    }
    catch (IllegalStateException ex) {
View Full Code Here

Examples of org.springframework.aop.framework.Lockable

  public void testCommonInterceptorAndAdvisor() throws Exception {
    BeanFactory bf = new ClassPathXmlApplicationContext("/org/springframework/aop/framework/autoproxy/advisorAutoProxyCreatorWithCommonInterceptors.xml");
    ITestBean test1 = (ITestBean) bf.getBean("test1");
    assertTrue(AopUtils.isAopProxy(test1));

    Lockable lockable1 = (Lockable) test1;
    NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
    assertEquals(0, nop.getCount());

    ITestBean test2 = (ITestBean) bf.getBean("test2");
    Lockable lockable2 = (Lockable) test2;
   
    // Locking should be independent; nop is shared
    assertFalse(lockable1.locked());
    assertFalse(lockable2.locked());
    // equals 2 calls on shared nop, because it's first
    // and sees calls against the Lockable interface introduced
    // by the specific advisor
    assertEquals(2, nop.getCount());
    lockable1.lock();
    assertTrue(lockable1.locked());
    assertFalse(lockable2.locked());
    assertEquals(5, nop.getCount());
  }
View Full Code Here

Examples of org.springframework.aop.framework.Lockable

    NotLockable notLockable1 = (NotLockable) createProxy(notLockableTarget,
        getFixture().getAdvisors(
            new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")),
        NotLockable.class);
    assertTrue(notLockable1 instanceof Lockable);
    Lockable lockable = (Lockable) notLockable1;
    assertFalse(lockable.locked());
    lockable.lock();
    assertTrue(lockable.locked());
   
    NotLockable notLockable2Target = new NotLockable();
    NotLockable notLockable2 = (NotLockable) createProxy(notLockable2Target,
        getFixture().getAdvisors(
            new SingletonMetadataAwareAspectInstanceFactory(new MakeLockable(),"someBean")),
        NotLockable.class);
    assertTrue(notLockable2 instanceof Lockable);
    Lockable lockable2 = (Lockable) notLockable2;
    assertFalse(lockable2.locked());
    notLockable2.setIntValue(1);
    lockable2.lock();
    try {
      notLockable2.setIntValue(32);
      fail();
    }
    catch (IllegalStateException ex) {
    }
    assertTrue(lockable2.locked());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.