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; }
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; }
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: 6 Number of AST nodes: 6
1
try {
1
try {
2
          Session session = sessionFactory.getCurrentSession();
2
          Session session = sessionFactory.getCurrentSession();
3
          Object account = session.get(acctClass, id);
3
          Object account = session.get(acctClass, id);
4
          setBranch.invoke(account, branch);
4
          setBalance.invoke(account, newBalance);
5
          session.update(account);
5
          session.update(account);
6
          tm.commit();
6
          tm.commit();
7
      }
7
      }
8
      catch (Exception e) {
8
      catch (Exception e) {
9
         log.error("rolling back", e);
9
          log.error("rolling back", e);
10
         tm.rollback();
10
          tm.rollback();
11
         throw e;
11
          throw e;
12
      }
12
      }
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 comparisons36
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    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();
    Precondition Violations (1)
    Row Violation
    1Type java.lang.String of variable branch does not match with type java.lang.Integer of variable newBalance