-
Notifications
You must be signed in to change notification settings - Fork 373
Closed
Description
Hi!
Using primitive arrays as named parameters causes ClassCastException in spring-data-jdbc-2.x.x
Simple example (PostgreSQL 8.4+):
@Query("select unnest( :ids )")
List<Integer> unnest(Integer[] ids);
@Query("select unnest( :ids )")
List<Integer> unnest(int[] ids);
First method works fine, but second throws ClassCastException when casting int[] to Object[]
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
at org.springframework.data.jdbc.core.convert.BasicJdbcConverter.writeJdbcValue(BasicJdbcConverter.java:320)
in return JdbcValue.of(typeFactory.createArray((Object[]) convertedValue), JDBCType.ARRAY);
On the other hand, in spring-data-jdbc-1.1.12 both methods work fine.
Tested on spring-data-jdbc-2.1.5 (SB 2.4.3) and spring-data-jdbc-1.1.12 (SB 2.2.13) (Java 8)
Configuration:
@Configuration
@EnableJdbcRepositories
public class JdbcConfiguration extends AbstractJdbcConfiguration {
@Bean
public NamedParameterJdbcOperations operations(DataSource dataSource) {
return new NamedParameterJdbcTemplate(dataSource);
}
@Bean
public PlatformTransactionManager transactionManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
}
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug