1 Reply Latest reply: May 11, 2012 8:38 AM by Cdelahun-Oracle RSS

    eclipselink unitofwork cache validation after commit

    newToplinkUser
      The following test case works fails when I use jdbc jdk 1.5 version of the library (Oracle 11g), I am getting an optimistic lock exception for uow2.commit().
      Where the same program works fine with Jdbc jdk 1.6 version, what are the dependencies of Eclipselink with JDBC library, why the update of the local
      cache object depend on jdbc library? thanks

      UnitOfWork uow = getPersistenceSession().acquireUnitOfWork();
      Rule rule = ( Rule ) uow.registerObject( RuleFactory.newRule() );
      rule.setShortName( "Test" + System.currentTimeMillis() );
      rule.putCustomField( "MinNotional", 110.0 );
      rule.putCustomField( "MaxNotional", 1000.0 );
      rule.putCustomField( "DirectFX_MinTenor", "1M" );
      rule.putCustomField( "DirectFX_MaxTenor", "1Y" );

      RuleCustomFieldC rcf1 = ( RuleCustomFieldC ) rule.getCustomField( "MinNotional" );
      RuleCustomFieldC rcf2 = ( RuleCustomFieldC ) rule.getCustomField( "MaxNotional" );
      RuleCustomFieldC rcf3 = ( RuleCustomFieldC ) rule.getCustomField( "DirectFX_MinTenor" );
      RuleCustomFieldC rcf4 = ( RuleCustomFieldC ) rule.getCustomField( "DirectFX_MaxTenor" );

      log( "######## BEFORE COMMIT ###########" );
      log( "MinNotional =           " + rcf1.getDouble() );
      log( "MaxNotional =           " + rcf2.getDouble() );
      log( "DirectFX_MinTenor =" + rcf3.getValue() );
      log( "DirectFX_MaxTenor =" + rcf4.getValue() );

      Rule ruleObj = ( Rule ) uow.registerObject( rule );
      ruleObj.putCustomField( "MinNotional", new Double( 40 ) );
      ruleObj.putCustomField( "DirectFX_MinTenor", "3M" );
      ruleObj.putCustomField( "DirectFX_MaxTenor", "6M" );

      uow.commit();

      log( "######## AFTER COMMIT ###########" );
      rcf1 = ( RuleCustomFieldC ) rule.getCustomField( "MinNotional" );
      rcf2 = ( RuleCustomFieldC ) rule.getCustomField( "MaxNotional" );
      rcf3 = ( RuleCustomFieldC ) rule.getCustomField( "DirectFX_MinTenor" );
      rcf4 = ( RuleCustomFieldC ) rule.getCustomField( "DirectFX_MaxTenor" );
      log( "MinNotional =           " + rcf1.getDouble() );
      log( "MaxNotional =           " + rcf2.getDouble() );
      log( "DirectFX_MinTenor =" + rcf3.getValue() );
      log( "DirectFX_MaxTenor =" + rcf4.getValue() );

      log( "######## BEFORE COMMIT 2 ###########" );
      UnitOfWork uow2 = getPersistenceSession().acquireUnitOfWork();
      ruleObj = ( Rule ) uow2.registerObject( rule );
      ruleObj.putCustomField( "MinNotional", new Double( 41 ) );
      ruleObj.putCustomField( "DirectFX_MinTenor", "4M" );
      ruleObj.putCustomField( "DirectFX_MaxTenor", "7M" );

      uow2.commit();

      log( "######## AFTER COMMIT 2 ###########" );
      rcf1 = ( RuleCustomFieldC ) rule.getCustomField( "MinNotional" );
      rcf2 = ( RuleCustomFieldC ) rule.getCustomField( "MaxNotional" );
      rcf3 = ( RuleCustomFieldC ) rule.getCustomField( "DirectFX_MinTenor" );
      rcf4 = ( RuleCustomFieldC ) rule.getCustomField( "DirectFX_MaxTenor" );
      log( "MinNotional =           " + rcf1.getDouble() );
      log( "MaxNotional =           " + rcf2.getDouble() );
      log( "DirectFX_MinTenor =" + rcf3.getValue() );
      log( "DirectFX_MaxTenor =" + rcf4.getValue() );

      Edited by: newToplinkUser on May 8, 2012 6:16 PM