-
Notifications
You must be signed in to change notification settings - Fork 131
Closed
Description
springboot version: 2.4.7
spring-data-r2dbc version: 1.2.9
entity:
public class MessageBody {
private String msg:
}
public class Message {
private Integer id;
private MessageBody body;
}Repository
public interface MessageRepository extends R2dbcRepository<Message, Integer> {
}when i call MessageRepository.save(), i get the exception:
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.dao.InvalidDataAccessApiUsageException: Nested entities are not supported
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: Nested entities are not supported
If change Message.body to String:
public class Message {
private Integer id;
private String body;
}get exception:
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.r2dbc.BadSqlGrammarException: executeMany; bad SQL grammar [INSERT INTO message (body) VALUES ($1)]; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: [42804] column "body" is of type json but expression is of type character varying
Caused by: org.springframework.r2dbc.BadSqlGrammarException: executeMany; bad SQL grammar [INSERT INTO message (body) VALUES ($1)]; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlBadGrammarException: [42804] column "body" is of type json but expression is of type character varying
after add @WritingConverter:
public class MessageBodyWriteConverter implements Converter<MessageBody, Json> {
@Override
public Json convert(MessageBody messageBody) {
return Json.of(new ObjectMapper().writeValueAsString(messageBody));
}
}get exception:
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.dao.DataIntegrityViolationException: executeMany; SQL [INSERT INTO message (body) VALUES ($1)]; null value in column "body" violates not-null constraint; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlDataIntegrityViolationException: [23502] null value in column "body" violates not-null constraint
Caused by: org.springframework.dao.DataIntegrityViolationException: executeMany; SQL [INSERT INTO message (body) VALUES ($1)]; null value in column "body" violates not-null constraint; nested exception is io.r2dbc.postgresql.ExceptionFactory$PostgresqlDataIntegrityViolationException: [23502] null value in column "body" violates not-null constraint
Metadata
Metadata
Assignees
Labels
type: taskA general taskA general task