@@ -15,6 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.r2dbc.repository.query;
|
package org.springframework.data.r2dbc.repository.query;
|
||||||
|
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import org.reactivestreams.Publisher;
|
||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.data.convert.EntityInstantiators;
|
import org.springframework.data.convert.EntityInstantiators;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
@@ -82,13 +87,31 @@ interface R2dbcQueryExecution {
|
|||||||
@Override
|
@Override
|
||||||
public Object convert(Object source) {
|
public Object convert(Object source) {
|
||||||
|
|
||||||
ReturnedType returnedType = this.processor.getReturnedType();
|
ReturnedType returnedType = processor.getReturnedType();
|
||||||
|
|
||||||
if (Void.class == returnedType.getReturnedType()
|
if (ClassUtils.isPrimitiveOrWrapper(returnedType.getReturnedType())) {
|
||||||
|| ClassUtils.isPrimitiveOrWrapper(returnedType.getReturnedType())) {
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mappingContext.hasPersistentEntityFor(returnedType.getReturnedType())) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Void.class == returnedType.getReturnedType()) {
|
||||||
|
|
||||||
|
if (source instanceof Mono) {
|
||||||
|
return ((Mono<?>) source).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source instanceof Publisher) {
|
||||||
|
return Flux.from((Publisher<?>) source).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ClassUtils.isPrimitiveOrWrapper(returnedType.getReturnedType())) {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Converter<Object, Object> converter = new DtoInstantiatingConverter(returnedType.getReturnedType(),
|
Converter<Object, Object> converter = new DtoInstantiatingConverter(returnedType.getReturnedType(),
|
||||||
this.mappingContext, this.instantiators);
|
this.mappingContext, this.instantiators);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user