WebLogic Server中CMP实体bean的性能调优[7]

发表于:2010-03-11来源:作者:点击数: 标签:CMPBeanWeblogic实体SERVER
WebLogic Server中CMP实体bean的性能调优[7] 性能测试工具 下面基于 Cactus 的测试验证了该行为。假定一个Person CMP bean是利用乐观并发部署的,并且cache-between-transaction被设置为true: ... public class OptimisticLockingTest extends Servlet Test

  WebLogic Server中CMP实体bean的性能调优[7]  性能测试工具 

   下面基于Cactus的测试验证了该行为。假定一个Person CMP bean是利用乐观并发部署的,并且cache-between-transaction被设置为true:

  ...

  public class OptimisticLockingTest extends ServletTestCase {

  private UserTransaction tx;

  protected void setUp() throws Exception {

  super.setUp();

  Context context = new InitialContext();

  this.tx = (UserTransaction)context

  .lookup("javax/transaction/UserTransaction");

  }

  public void testCacheBetweenTransactions() throws Exception {

  PersonLocalHome localHome = (PersonLocalHome)Locator

  .getLocalHome(PersonLocalHome.JNDI_NAME);

  // create record via CMP in first transaction

  this.tx.begin();

  PersonLocal local = localHome.create();

  local.setName("John");

  Long pk = local.getPrimaryKey();

  this.tx.commit();

  // update some field(s) via direct JDBC call in another

  // transaction. Assume that updatePersonNameViaJdbc()

  // method will update version column as well

  String newName = "Paul";

  this.tx.begin();

  updatePersonNameViaJdbc(pk, newName);

  this.tx.commit();

  // find CMP again and try to update name in yet

  // another transaction

原文转自:http://www.ltesting.net