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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATACASS-343-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data for Apache Cassandra</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-cql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATACASS-343-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-cassandra-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATACASS-343-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion spring-data-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATACASS-343-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ public interface CassandraConverter
* Converts the given object into one Cassandra will be able to store natively in a column.
*
* @param obj {@link Object} to convert, must not be {@literal null}.
* @param typeInformation {@link TypeInformation} used to describe the object type; must not be {@literal null}.
* @return the result of the conversion.
* @since 2.0
*/
<T> Optional<Object> convertToCassandraColumn(Optional<T> obj);

/**
* Converts the given object into one Cassandra will be able to store natively in a column.
*
* @param obj {@link Object} to convert, must not be {@literal null}.
* @param typeInformation {@link TypeInformation} used to describe the object type; may be {@literal null}.
* @return the result of the conversion.
* @since 1.5
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ public <R> R read(Class<R> type, Object row) {
throw new MappingException("Unknown row object " + ObjectUtils.nullSafeClassName(row));
}

/* (non-Javadoc)
* @see org.springframework.data.cassandra.convert.CassandraConverter#convertToCassandraColumn(java.util.Optional)
*/
@Override
@SuppressWarnings("unchecked")
public <T> Optional<Object> convertToCassandraColumn(Optional<T> obj) {

return convertToCassandraColumn(obj,
obj.map(Object::getClass) //
.map(ClassTypeInformation::from) //
.orElse((ClassTypeInformation) ClassTypeInformation.OBJECT));
}

/* (non-Javadoc)
* @see org.springframework.data.cassandra.convert.CassandraConverter#convertToCassandraColumn(java.util.Optional, org.springframework.data.util.TypeInformation)
*/
Expand Down Expand Up @@ -677,6 +690,12 @@ private <I, O> Optional<O> getWriteValue(Optional<I> optional, TypeInformation<?
(Class<O>) getCustomConversions().getCustomWriteTarget(value.getClass())));
}

if (getCustomConversions().isSimpleType(value.getClass())) {
// Doesn't need conversion
return getPotentiallyConvertedSimpleValue(optional,
typeInformation != null ? (Class<O>) typeInformation.getType() : null);
}

TypeInformation<?> type = (typeInformation != null ? typeInformation : ClassTypeInformation.from(value.getClass()));
TypeInformation<?> actualType = type.getActualType();

Expand Down
Loading