Conflicts:
	hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/ClobTypeDescriptor.java
This commit is contained in:
Vincent Cornet 2013-02-14 15:55:01 -05:00 committed by Brett Meyer
parent 9069d7aed9
commit 98e3b2ab97
1 changed files with 59 additions and 29 deletions

View File

@ -53,32 +53,6 @@ public abstract class ClobTypeDescriptor implements SqlTypeDescriptor {
return true;
}
@Override
public <X> ValueExtractor<X> getExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicExtractor<X>( javaTypeDescriptor, this ) {
@Override
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
return javaTypeDescriptor.wrap( rs.getClob( name ), options );
}
@Override
protected X doExtract(CallableStatement statement, int index, WrapperOptions options) throws SQLException {
return javaTypeDescriptor.wrap( statement.getClob( index ), options );
}
@Override
protected X doExtract(CallableStatement statement, String name, WrapperOptions options) throws SQLException {
return javaTypeDescriptor.wrap( statement.getClob( name ), options );
}
};
}
protected abstract <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor);
public <X> ValueBinder<X> getBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return getClobBinder( javaTypeDescriptor );
}
public static final ClobTypeDescriptor DEFAULT =
new ClobTypeDescriptor() {
@ -86,7 +60,8 @@ public abstract class ClobTypeDescriptor implements SqlTypeDescriptor {
SqlTypeDescriptorRegistry.INSTANCE.addDescriptor( this );
}
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
@Override
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
@ -99,11 +74,27 @@ public abstract class ClobTypeDescriptor implements SqlTypeDescriptor {
}
};
}
@Override
public <X> BasicExtractor<X> getClobExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicExtractor<X>( javaTypeDescriptor, this ) {
@Override
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
if ( options.useStreamForLobBinding() ) {
return STREAM_BINDING.getClobExtractor( javaTypeDescriptor ).doExtract( rs, name, options );
}
else {
return CLOB_BINDING.getClobExtractor( javaTypeDescriptor ).doExtract( rs, name, options );
}
}
};
}
};
public static final ClobTypeDescriptor CLOB_BINDING =
new ClobTypeDescriptor() {
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
@Override
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
@ -112,11 +103,24 @@ public abstract class ClobTypeDescriptor implements SqlTypeDescriptor {
}
};
}
@Override
public <X> BasicExtractor<X> getClobExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicExtractor<X>(javaTypeDescriptor, this) {
@Override
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
return javaTypeDescriptor.wrap( rs.getClob( name ), options );
}
};
};
};
public static final ClobTypeDescriptor STREAM_BINDING =
new ClobTypeDescriptor() {
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
@Override
public <X> BasicBinder<X> getClobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicBinder<X>( javaTypeDescriptor, this ) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options)
@ -126,6 +130,32 @@ public abstract class ClobTypeDescriptor implements SqlTypeDescriptor {
}
};
}
@Override
public <X> BasicExtractor<X> getClobExtractor(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new BasicExtractor<X>(javaTypeDescriptor, this) {
@Override
protected X doExtract(ResultSet rs, String name, WrapperOptions options) throws SQLException {
return javaTypeDescriptor.wrap( rs.getCharacterStream( name ), options );
}
};
};
};
protected abstract <X> BasicBinder<X> getClobBinder(JavaTypeDescriptor<X> javaTypeDescriptor);
protected abstract <X> BasicExtractor<X> getClobExtractor(JavaTypeDescriptor<X> javaTypeDescriptor);
@Override
public <X> ValueBinder<X> getBinder(JavaTypeDescriptor<X> javaTypeDescriptor) {
return getClobBinder( javaTypeDescriptor );
}
@Override
public <X> ValueExtractor<X> getExtractor(JavaTypeDescriptor<X> javaTypeDescriptor) {
return getClobExtractor( javaTypeDescriptor );
}
}