Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.math.BigDecimal;
import java.sql.JDBCType;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -182,6 +183,19 @@ void saveAndLoadListOfDirectionsAsArray() {
assertThat(reloaded).isEqualTo(saved);
}

@Test
@EnabledOnFeature(TestDatabaseFeatures.Feature.SUPPORTS_ARRAYS)
void saveAndLoadListOfNullAsArray() {
var list = new ArrayList<Direction>();
list.add(null);

EntityWithDirections saved = repositoryWithDirections.save(new EntityWithDirections(null, list));

EntityWithDirections reloaded = repositoryWithDirections.findById(saved.id).orElseThrow();

assertThat(reloaded).isEqualTo(saved);
}

interface EntityWithStringyBigDecimalRepository extends CrudRepository<EntityWithStringyBigDecimal, CustomId> {

@Query("SELECT * FROM ENTITY_WITH_STRINGY_BIG_DECIMAL WHERE DIRECTION IN (:types)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,16 +809,7 @@ private Object writeCollection(Iterable<?> value, TypeInformation<?> type) {
return mapped;
}

// if we succeeded converting the members of the collection, we actually ignore the fallback targetType since that
// was derived without considering custom conversions.
Class<?> targetType = type.getType();
if (!mapped.isEmpty()) {

Class<?> targetComponentType = mapped.get(0).getClass();
targetType = Array.newInstance(targetComponentType, 0).getClass();
}

Object converted = getConversionService().convert(mapped, targetType);
Object converted = getConversionService().convert(mapped, type.getType());

Assert.state(converted != null, "Converted must not be null");

Expand Down