From 3f7d8a4f160487eec52cabeaa73df4f15e41e998 Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 7 Apr 2020 19:09:35 +0800 Subject: [PATCH] =?UTF-8?q?DEC-12783=20=E3=80=90=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E8=BF=81=E7=A7=BBdb2=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=A4=9A=E8=AF=AD=E8=A8=80=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0key=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cfg/annotations/SimpleValueBinder.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java b/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java index c80d9f1c1..3251b86e6 100644 --- a/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java +++ b/fine-hibernate/src/com/fr/third/org/hibernate/cfg/annotations/SimpleValueBinder.java @@ -54,6 +54,7 @@ import com.fr.third.org.hibernate.type.PrimitiveCharacterArrayNClobType; import com.fr.third.org.hibernate.type.SerializableToBlobType; import com.fr.third.org.hibernate.type.StandardBasicTypes; import com.fr.third.org.hibernate.type.StringNVarcharType; +import com.fr.third.org.hibernate.type.StringType; import com.fr.third.org.hibernate.type.WrappedMaterializedBlobType; import com.fr.third.org.hibernate.usertype.DynamicParameterizedType; @@ -89,6 +90,14 @@ public class SimpleValueBinder { private AttributeConverterDescriptor attributeConverterDescriptor; + private static String DRIVER_CLASS; + + private static final String DB2_PREFIX = "db2"; + + public static void setDriverClass(String driverClass) { + DRIVER_CLASS = driverClass; + } + public void setReferencedEntityName(String referencedEntityName) { this.referencedEntityName = referencedEntityName; } @@ -278,7 +287,7 @@ public class SimpleValueBinder { else if ( isNationalized ) { if ( buildingContext.getBuildingOptions().getReflectionManager().equals( returnedClassOrElement, String.class ) ) { // nvarchar - type = StringNVarcharType.INSTANCE.getName(); + type = DRIVER_CLASS != null && DRIVER_CLASS.contains(DB2_PREFIX) ? StringType.INSTANCE.getName() : StringNVarcharType.INSTANCE.getName(); explicitType = type; } else if ( buildingContext.getBuildingOptions().getReflectionManager().equals( returnedClassOrElement, Character.class ) || @@ -454,7 +463,7 @@ public class SimpleValueBinder { public void fillSimpleValue() { LOG.debugf( "Starting fillSimpleValue for %s", propertyName ); - + if ( attributeConverterDescriptor != null ) { if ( ! BinderHelper.isEmptyAnnotationValue( explicitType ) ) { throw new AnnotationException( @@ -531,7 +540,7 @@ public class SimpleValueBinder { if ( timeStampVersionType != null ) { simpleValue.setTypeName( timeStampVersionType ); } - + if ( simpleValue.getTypeName() != null && simpleValue.getTypeName().length() > 0 && simpleValue.getMetadata().getTypeResolver().basic( simpleValue.getTypeName() ) == null ) { try {