log.debug("Updating account " + id + " to branch " + branch); tm.begin(); try { Session session = sessionFactory.getCurrentSession(); Object account = session.get(acctClass, id); setBranch.invoke(account, branch); session.update(account); tm.commit(); } catch (Exception e) { log.error("rolling back", e); tm.rollback(); throw e; } log.debug("Updated account " + id + " to branch " + branch);
log.debug("Updating account " + id + " to balance " + newBalance); tm.begin(); try { Session session = sessionFactory.getCurrentSession(); Object account = session.get(acctClass, id); setBalance.invoke(account, newBalance); session.update(account); tm.commit(); } catch (Exception e) { log.error("rolling back", e); tm.rollback(); throw e; } log.debug("Updated account " + id + " to balance " + newBalance);
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/classloader/ClassLoaderTestDAO.java File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/classloader/ClassLoaderTestDAO.java
Method name: void updateAccountBranch(Integer, String) Method name: void updateAccountBalance(Integer, Integer)
Number of AST nodes: 9 Number of AST nodes: 9
1
log.debug("Updating account " + id + " to branch " + branch);
1
log.debug("Updating account " + id + " to balance " + newBalance);
2
      tm.begin();
2
      tm.begin();
3
      try {
3
      try {
4
          Session session = sessionFactory.getCurrentSession();
4
          Session session = sessionFactory.getCurrentSession();
5
          Object account = session.get(acctClass, id);
5
          Object account = session.get(acctClass, id);
6
          setBranch.invoke(account, branch);
6
          setBalance.invoke(account, newBalance);
7
          session.update(account);
7
          session.update(account);
8
          tm.commit();
8
          tm.commit();
9
      }
9
      }
10
      catch (Exception e) {
10
      catch (Exception e) {
11
         log.error("rolling back", e);
11
          log.error("rolling back", e);
12
         tm.rollback();
12
          tm.rollback();
13
         throw e;
13
          throw e;
14
      }
14
      }
15
      log.debug("Updated account " + id + " to branch " + branch);
15
      log.debug("Updated account " + id + " to balance " + newBalance);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons45
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)4.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    log.debug("Updating account " + id + " to branch " + branch);
    1
    log.debug("Updating account " + id + " to branch " + branch);
    1
    log.debug("Updating account " + id + " to balance " + newBalance);
    Differences
    Expression1Expression2Difference
    " to branch "" to balance "LITERAL_VALUE_MISMATCH
    branchnewBalanceVARIABLE_NAME_MISMATCH
    java.lang.Stringjava.lang.IntegerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance
    • Make classes java.lang.String and java.lang.Integer extend a common superclass
    1
    log.debug("Updating account " + id + " to balance " + newBalance);
    2
    tm.begin();
    2
    tm.begin();
    3
    try
    3
    try
    4
    Session session = sessionFactory.getCurrentSession();
    4
    Session session = sessionFactory.getCurrentSession();
    5
    Object account = session.get(acctClass, id);
    5
    Object account = session.get(acctClass, id);
    6
    setBranch.invoke(account, branch);
    6
    setBranch.invoke(account, branch);
    6
    setBalance.invoke(account, newBalance);
    Differences
    Expression1Expression2Difference
    branchnewBalanceVARIABLE_NAME_MISMATCH
    java.lang.Stringjava.lang.IntegerVARIABLE_TYPE_MISMATCH
    setBranchsetBalanceVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance
    • Make classes java.lang.String and java.lang.Integer extend a common superclass
    6
    setBalance.invoke(account, newBalance);
    7
    session.update(account);
    7
    session.update(account);
    8
    tm.commit();
    8
    tm.commit();
    9
    log.debug("Updated account " + id + " to branch " + branch);
    9
    log.debug("Updated account " + id + " to branch " + branch);
    9
    log.debug("Updated account " + id + " to balance " + newBalance);
    Differences
    Expression1Expression2Difference
    " to branch "" to balance "LITERAL_VALUE_MISMATCH
    branchnewBalanceVARIABLE_NAME_MISMATCH
    java.lang.Stringjava.lang.IntegerVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance
    • Make classes java.lang.String and java.lang.Integer extend a common superclass
    9
    log.debug("Updated account " + id + " to balance " + newBalance);
    Precondition Violations (3)
    Row Violation
    1Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance
    2Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance
    3Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance