I have a Spring Boot application with reactive stack (WebFlux). I work with PostgreSQL database using r2dbc driver. DB contains 2 records with all values present, but when I query I get empty fields. Below you can see the service response.
[
{
"pkey": null,
"description": null,
"uid": null,
"isActive": null
},
{
"pkey": null,
"description": null,
"uid": null,
"isActive": null
}
]
Entity class:
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Immutable;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;
@Getter
@Setter
@Builder
@ToString
@Immutable
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "channel", schema = "myschema")
public class ChannelView {
@Id
@Column("pkey")
private Integer pkey;
@Column("description")
private String description;
@Column("uid")
private String uid;
@Column("is_active")
private Boolean isActive;
}
Data received through reactive repo using its default generated findAll() method:
import com.myproject.dao.entity.ChannelView;
import org.springframework.data.r2dbc.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Mono;
@Repository
public interface ChannelViewRepository extends ReactiveCrudRepository<ChannelView, Integer> {
}
Note that channel is actually a view, not a table. Probably it's the problem. But in non-reactive approach it works right (jdbc driver).