Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Event theEvent = new Event(); theEvent.setTitle(title); theEvent.setDate(theDate); session.save(theEvent); session.getTransaction().commit(); return theEvent.getId();
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Person thePerson = new Person(); thePerson.setFirstname(firstname); thePerson.setLastname(lastname); session.save(thePerson); session.getTransaction().commit(); return thePerson.getId();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/tutorials/web/src/main/java/org/hibernate/tutorial/web/EventManager.java File path: /hibernate-distribution-3.3.2.GA/project/tutorials/web/src/main/java/org/hibernate/tutorial/web/EventManager.java
Method name: Long createAndStoreEvent(String, Date) Method name: Long createAndStorePerson(String, String)
Number of AST nodes: 8 Number of AST nodes: 8
1
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
1
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
2
        session.beginTransaction();
2
        session.beginTransaction();
3
        Event theEvent = new Event();
3
        Person thePerson = new Person();
4
        theEvent.setTitle(title);
4
        thePerson.setFirstname(firstname);
5
        theEvent.setDate(theDate);
5
        thePerson.setLastname(lastname);
6
        session.save(theEvent);
6
        session.save(thePerson);
7
        session.getTransaction().commit();
7
        session.getTransaction().commit();
8
        return theEvent.getId();
8
        return thePerson.getId();
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.0
Clones locationClones are declared in the same class
Number of node comparisons64
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)0.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    1
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    2
    session.beginTransaction();
    2
    session.beginTransaction();
                                                                      
    3
    Person thePerson = new Person();
    3
    Event theEvent = new Event();
                                                                
                                                                              
    4
    thePerson.setFirstname(firstname);
    Preondition Violations
    Unmatched statement thePerson.setFirstname(firstname); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4
    thePerson.setFirstname(firstname);
    4
    theEvent.setTitle(title);
    4
    theEvent.setTitle(title);
    Preondition Violations
    Unmatched statement theEvent.setTitle(title); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                            
                                                                          
    5
    thePerson.setLastname(lastname);
    Preondition Violations
    Unmatched statement thePerson.setLastname(lastname); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5
    thePerson.setLastname(lastname);
    5
    theEvent.setDate(theDate);
    5
    theEvent.setDate(theDate);
    Preondition Violations
    Unmatched statement theEvent.setDate(theDate); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                              
    6
    session.save(theEvent);
    6
    session.save(theEvent);
    6
    session.save(thePerson);
    Differences
    Expression1Expression2Difference
    theEventthePersonVARIABLE_NAME_MISMATCH
    org.hibernate.tutorial.domain.Eventorg.hibernate.tutorial.domain.PersonVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.tutorial.domain.Event of variable theEvent does not match with type org.hibernate.tutorial.domain.Person of variable thePerson
    • Make classes org.hibernate.tutorial.domain.Event and org.hibernate.tutorial.domain.Person extend a common superclass
    6
    session.save(thePerson);
    7
    session.getTransaction().commit();
    7
    session.getTransaction().commit();
    8
    return theEvent.getId();
    8
    return theEvent.getId();
    8
    return thePerson.getId();
    Differences
    Expression1Expression2Difference
    theEventthePersonVARIABLE_NAME_MISMATCH
    org.hibernate.tutorial.domain.Eventorg.hibernate.tutorial.domain.PersonVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.hibernate.tutorial.domain.Event of variable theEvent does not match with type org.hibernate.tutorial.domain.Person of variable thePerson
    • Make classes org.hibernate.tutorial.domain.Event and org.hibernate.tutorial.domain.Person extend a common superclass
    8
    return thePerson.getId();
    Precondition Violations (6)
    Row Violation
    1Unmatched statement thePerson.setFirstname(firstname); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    2Unmatched statement theEvent.setTitle(title); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    3Unmatched statement thePerson.setLastname(lastname); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    4Unmatched statement theEvent.setDate(theDate); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    5Type org.hibernate.tutorial.domain.Event of variable theEvent does not match with type org.hibernate.tutorial.domain.Person of variable thePerson
    6Type org.hibernate.tutorial.domain.Event of variable theEvent does not match with type org.hibernate.tutorial.domain.Person of variable thePerson