diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java index f7e2da1f21..e75ae1eaf9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java @@ -110,9 +110,16 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware if (!String.class.isAssignableFrom(sourceType.getType())) { PropertyEditor editor = delegate.findCustomEditor(sourceType.getType(), null); + if (editor==null) { + editor = delegate.getDefaultEditor(sourceType.getType()); + } if (editor != null){ // INT-1441 editor.setValue(value); - return editor.getAsText(); + String text = editor.getAsText(); + if (String.class.isAssignableFrom(targetType.getClass())) { + return text; + } + return convertValue(text, TypeDescriptor.valueOf(String.class), targetType); } } return delegate.convertIfNecessary(value, targetType.getType()); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java index b71b00ab7e..67aec87076 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/util/BeanFactoryTypeConverterTests.java @@ -6,9 +6,12 @@ package org.springframework.integration.util; import static junit.framework.Assert.assertEquals; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; import java.util.List; import org.junit.Test; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.core.convert.TypeDescriptor; /** @@ -27,4 +30,22 @@ public class BeanFactoryTypeConverterTests { (ArrayList) typeConverter.convertValue(sourceObject, null, TypeDescriptor.forObject(new ArrayList())); assertEquals(sourceObject, convertedCollection); } + + @Test + public void testToStringConversion(){ + BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(); + typeConverter.setBeanFactory(new DefaultListableBeanFactory()); + String converted = (String) typeConverter.convertValue(new Integer(1234), TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(String.class)); + assertEquals("1234", converted); + } + + @Test + public void testToNonStringConversionNotSupportedByGenericConversionService(){ + BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter(); + typeConverter.setBeanFactory(new DefaultListableBeanFactory()); + @SuppressWarnings("unchecked") + Collection converted = (Collection) typeConverter.convertValue(new Integer(1234), TypeDescriptor.valueOf(Integer.class), TypeDescriptor.forObject(new ArrayList(Arrays.asList(1)))); + assertEquals(Arrays.asList(1234), converted); + } + } diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-db2.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-db2.sql index 9d3188ff62..1893dc9a6b 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-db2.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-db2.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP, + UPDATED_DATE TIMESTAMP DEFAULT NULL, MESSAGE_BYTES BLOB, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-derby.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-derby.sql index 9d3188ff62..1893dc9a6b 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-derby.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-derby.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP, + UPDATED_DATE TIMESTAMP DEFAULT NULL, MESSAGE_BYTES BLOB, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-h2.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-h2.sql index 1ce0f26631..1d48022272 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-h2.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-h2.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP, + UPDATED_DATE TIMESTAMP DEFAULT NULL, MESSAGE_BYTES LONGVARBINARY, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-hsqldb.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-hsqldb.sql index 1ce0f26631..1d48022272 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-hsqldb.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-hsqldb.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP, + UPDATED_DATE TIMESTAMP DEFAULT NULL, MESSAGE_BYTES LONGVARBINARY, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-mysql.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-mysql.sql index 7dc583c223..d43468164a 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-mysql.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-mysql.sql @@ -5,7 +5,7 @@ CREATE TABLE INT_MESSAGE ( REGION VARCHAR(100), CREATED_DATE DATETIME NOT NULL, MESSAGE_BYTES BLOB -); +) ENGINE=InnoDB; CREATE TABLE INT_MESSAGE_GROUP ( MESSAGE_ID CHAR(36) NOT NULL, @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE DATETIME NOT NULL, - UPDATED_DATE DATETIME, + UPDATED_DATE DATETIME DEFAULT NULL, MESSAGE_BYTES BLOB, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) -); +) ENGINE=InnoDB; diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-oracle10g.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-oracle10g.sql index cb1b32d419..b549ce9004 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-oracle10g.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-oracle10g.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR2(100), MARKED NUMBER(19,0), CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP, + UPDATED_DATE TIMESTAMP DEFAULT NULL, MESSAGE_BYTES BLOB, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-postgresql.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-postgresql.sql index c11fe43b19..7e7654c24a 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-postgresql.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-postgresql.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE TIMESTAMP NOT NULL, - UPDATED_DATE TIMESTAMP, + UPDATED_DATE TIMESTAMP DEFAULT NULL, MESSAGE_BYTES BYTEA, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sqlserver.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sqlserver.sql index c921ebb6c7..1c2fccb438 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sqlserver.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sqlserver.sql @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE DATETIME NOT NULL, - UPDATED_DATE DATETIME, + UPDATED_DATE DATETIME DEFAULT NULL, MESSAGE_BYTES IMAGE, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) ); diff --git a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sybase.sql b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sybase.sql index c921ebb6c7..1d00ea955e 100644 --- a/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sybase.sql +++ b/spring-integration-jdbc/src/main/resources/org/springframework/integration/jdbc/schema-sybase.sql @@ -5,7 +5,7 @@ CREATE TABLE INT_MESSAGE ( REGION VARCHAR(100), CREATED_DATE DATETIME NOT NULL, MESSAGE_BYTES IMAGE -); +) LOCK DATAROWS WITH EXP_ROW_SIZE=1; CREATE TABLE INT_MESSAGE_GROUP ( MESSAGE_ID CHAR(36) NOT NULL, @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION VARCHAR(100), MARKED BIGINT, CREATED_DATE DATETIME NOT NULL, - UPDATED_DATE DATETIME, + UPDATED_DATE DATETIME DEFAULT NULL, MESSAGE_BYTES IMAGE, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) -); +) LOCK DATAROWS WITH EXP_ROW_SIZE=1; diff --git a/spring-integration-jdbc/src/main/sql/schema.sql.vpp b/spring-integration-jdbc/src/main/sql/schema.sql.vpp index 4b53880097..c8abfd212f 100644 --- a/spring-integration-jdbc/src/main/sql/schema.sql.vpp +++ b/spring-integration-jdbc/src/main/sql/schema.sql.vpp @@ -5,7 +5,7 @@ CREATE TABLE INT_MESSAGE ( REGION ${VARCHAR}(100), CREATED_DATE ${TIMESTAMP} NOT NULL, MESSAGE_BYTES ${BLOB} -); +)#if(${VOODOO}) ${VOODOO}#end; CREATE TABLE INT_MESSAGE_GROUP ( MESSAGE_ID CHAR(36) NOT NULL, @@ -13,7 +13,7 @@ CREATE TABLE INT_MESSAGE_GROUP ( REGION ${VARCHAR}(100), MARKED ${BIGINT}, CREATED_DATE ${TIMESTAMP} NOT NULL, - UPDATED_DATE ${TIMESTAMP}, + UPDATED_DATE ${TIMESTAMP} DEFAULT NULL, MESSAGE_BYTES ${BLOB}, constraint MESSAGE_GROUP_PK primary key (MESSAGE_ID, GROUP_KEY) -); +)#if(${VOODOO}) ${VOODOO}#end; diff --git a/spring-integration-jdbc/src/main/sql/sybase.properties b/spring-integration-jdbc/src/main/sql/sybase.properties index 78adc66a1c..5e9c2c5e5d 100644 --- a/spring-integration-jdbc/src/main/sql/sybase.properties +++ b/spring-integration-jdbc/src/main/sql/sybase.properties @@ -10,3 +10,4 @@ VARCHAR = VARCHAR NULL = NULL # for generating drop statements... SEQUENCE = TABLE +VOODOO = LOCK DATAROWS