if (value==null) { st.setNull(index, Types.BLOB); } else { if (value instanceof SerializableBlob) { value = ( (SerializableBlob) value ).getWrappedBlob(); } final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob() && (value instanceof BlobImpl); if ( useInputStream ) { BlobImpl blob = (BlobImpl) value; st.setBinaryStream( index, blob.getBinaryStream(), (int) blob.length() ); } else { st.setBlob(index, (Blob) value); } }
if (value==null) { st.setNull(index, Types.CLOB); } else { if (value instanceof SerializableClob) { value = ( (SerializableClob) value ).getWrappedClob(); } final boolean useReader = session.getFactory().getDialect().useInputStreamToInsertBlob() && (value instanceof ClobImpl); if ( useReader ) { ClobImpl clob = (ClobImpl) value; st.setCharacterStream( index, clob.getCharacterStream(), (int) clob.length() ); } else { st.setClob(index, (Clob) value); } }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/BlobType.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/type/ClobType.java
Method name: void set(PreparedStatement, Object, int, SessionImplementor) Method name: void set(PreparedStatement, Object, int, SessionImplementor)
Number of AST nodes: 9 Number of AST nodes: 9
1
if (value==null) {
1
if (value==null) {
2
			st.setNull(index, Types.BLOB);
2
			st.setNull(index, Types.CLOB);
3
		}
3
		}
4
		else {
4
		else {
5
			
5
		
6
			if (value instanceof SerializableBlob) {
6
			if (value instanceof SerializableClob) {
7
				value = ( (SerializableBlob) value ).getWrappedBlob();
7
				value = ( (SerializableClob) value ).getWrappedClob();
8
			}
8
			}
9
		
9
		
10
			final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob() && 
10
			final boolean useReader = session.getFactory().getDialect().useInputStreamToInsertBlob() && 
11
				(value instanceof BlobImpl);
11
				(value instanceof ClobImpl);
12
			
12
			
13
			if ( useInputStream ) {
13
			if ( useReader ) {
14
				BlobImpl blob = (BlobImpl) value;
14
				ClobImpl clob = (ClobImpl) value;
15
				st.setBinaryStream( index, blob.getBinaryStream(), (int) blob.length() );
15
				st.setCharacterStream( index, clob.getCharacterStream(), (int) clob.length() );
16
			}
16
			}
17
			else {
17
			else {
18
				st.setBlob(index, (Blob) value);
18
				st.setClob(index, (Clob) value);
19
			}
19
			}
20
			
20
			
21
		}
21
		}
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 in different classes having the same super class
Number of node comparisons31
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)4.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (value == null)
    1
    if (value == null)
    2
    st.setNull(index, Types.BLOB);
    2
    st.setNull(index, Types.BLOB);
    2
    st.setNull(index, Types.CLOB);
    Differences
    Expression1Expression2Difference
    BLOBCLOBVARIABLE_NAME_MISMATCH
    2
    st.setNull(index, Types.CLOB);
    else
    else
    3
    if (value instanceof SerializableBlob)
    3
    if (value instanceof SerializableBlob)
    3
    if (value instanceof SerializableClob)
    Differences
    Expression1Expression2Difference
    org.hibernate.lob.SerializableBloborg.hibernate.lob.SerializableClobVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression value instanceof SerializableBlob cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression value instanceof SerializableClob cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.lob.SerializableBlob does not match with type org.hibernate.lob.SerializableClob
    • Make classes org.hibernate.lob.SerializableBlob and org.hibernate.lob.SerializableClob extend a common superclass
    3
    if (value instanceof SerializableClob)
                                                                                                            
    4
    value = ((SerializableClob)value).getWrappedClob();
    Preondition Violations
    Unmatched statement value=((SerializableClob)value).getWrappedClob(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4
    value = ((SerializableClob)value).getWrappedClob();
    4
    value = ((SerializableBlob)value).getWrappedBlob();
    4
    value = ((SerializableBlob)value).getWrappedBlob();
    Preondition Violations
    Unmatched statement value=((SerializableBlob)value).getWrappedBlob(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                            
    5
    final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob() && (value instanceof BlobImpl);
    5
    final boolean useInputStream = session.getFactory().getDialect().useInputStreamToInsertBlob() && (value instanceof BlobImpl);
    5
    final boolean useReader = session.getFactory().getDialect().useInputStreamToInsertBlob() && (value instanceof ClobImpl);
    Differences
    Expression1Expression2Difference
    useInputStreamuseReaderVARIABLE_NAME_MISMATCH
    org.hibernate.lob.BlobImplorg.hibernate.lob.ClobImplVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression value instanceof BlobImpl cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression value instanceof ClobImpl cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type org.hibernate.lob.BlobImpl does not match with type org.hibernate.lob.ClobImpl
    • Make classes org.hibernate.lob.BlobImpl and org.hibernate.lob.ClobImpl extend a common superclass
    5
    final boolean useReader = session.getFactory().getDialect().useInputStreamToInsertBlob() && (value instanceof ClobImpl);
    6
    if (useInputStream)
    6
    if (useInputStream)
    6
    if (useReader)
    Differences
    Expression1Expression2Difference
    useInputStreamuseReaderVARIABLE_NAME_MISMATCH
    6
    if (useReader)
                                                                      
    7
    ClobImpl clob = (ClobImpl)value;
    Preondition Violations
    Unmatched statement ClobImpl clob=(ClobImpl)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    7
    ClobImpl clob = (ClobImpl)value;
    7
    BlobImpl blob = (BlobImpl)value;
    7
    BlobImpl blob = (BlobImpl)value;
    Preondition Violations
    Unmatched statement BlobImpl blob=(BlobImpl)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
                                                                      
                                                                                                                                                              
    8
    st.setCharacterStream(index, clob.getCharacterStream(), (int)clob.length());
    Preondition Violations
    Unmatched statement st.setCharacterStream(index,clob.getCharacterStream(),(int)clob.length()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement st.setCharacterStream(index,clob.getCharacterStream(),(int)clob.length()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    8
    st.setCharacterStream(index, clob.getCharacterStream(), (int)clob.length());
    8
    st.setBinaryStream(index, blob.getBinaryStream(), (int)blob.length());
    8
    st.setBinaryStream(index, blob.getBinaryStream(), (int)blob.length());
    Preondition Violations
    Unmatched statement st.setBinaryStream(index,blob.getBinaryStream(),(int)blob.length()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement st.setBinaryStream(index,blob.getBinaryStream(),(int)blob.length()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                                                                  
    else
    else
    9
    st.setBlob(index, (Blob)value);
    9
    st.setBlob(index, (Blob)value);
    9
    st.setClob(index, (Clob)value);
    Differences
    Expression1Expression2Difference
    java.sql.Blobjava.sql.ClobVARIABLE_TYPE_MISMATCH
    setBlobsetClobMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression (Blob)value cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression (Clob)value cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.sql.Blob does not match with type java.sql.Clob
    • Make classes java.sql.Blob and java.sql.Clob extend a common superclass
    Expression st.setBlob(index,(Blob)value) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression st.setClob(index,(Clob)value) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression st.setBlob(index,(Blob)value) is a void method call, and thus it cannot be parameterized
    Expression st.setClob(index,(Clob)value) is a void method call, and thus it cannot be parameterized
    9
    st.setClob(index, (Clob)value);
    Precondition Violations (21)
    Row Violation
    1Expression value instanceof SerializableBlob cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression value instanceof SerializableClob cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type org.hibernate.lob.SerializableBlob does not match with type org.hibernate.lob.SerializableClob
    4Unmatched statement value=((SerializableClob)value).getWrappedClob(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement value=((SerializableBlob)value).getWrappedBlob(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Expression value instanceof BlobImpl cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression value instanceof ClobImpl cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Type org.hibernate.lob.BlobImpl does not match with type org.hibernate.lob.ClobImpl
    9Unmatched statement ClobImpl clob=(ClobImpl)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement BlobImpl blob=(BlobImpl)value; cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    11Unmatched statement st.setCharacterStream(index,clob.getCharacterStream(),(int)clob.length()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched statement st.setCharacterStream(index,clob.getCharacterStream(),(int)clob.length()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    13Unmatched statement st.setBinaryStream(index,blob.getBinaryStream(),(int)blob.length()); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    14Unmatched statement st.setBinaryStream(index,blob.getBinaryStream(),(int)blob.length()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    15Expression (Blob)value cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression (Clob)value cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Type java.sql.Blob does not match with type java.sql.Clob
    18Expression st.setBlob(index,(Blob)value) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression st.setClob(index,(Clob)value) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Expression st.setBlob(index,(Blob)value) is a void method call, and thus it cannot be parameterized
    21Expression st.setClob(index,(Clob)value) is a void method call, and thus it cannot be parameterized