1

In spring-data-jdbc 2.3.2 with 2.6.4 data-jdbc starter. I am seeing the following output. Not clear if this is my error in a model layer or an issue with the framework.

This happens when the root aggregate tries to get updated because of a one-to-many reference modification.

As far as I can tell the SQL spec expects a SET statement here. This is the exception I am getting :

Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE "tb_entity" WHERE "tb_entity"."field_id" = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near "WHERE" Position: 21

Any suggestion is welcome.

RF1991
  • 2,037
  • 4
  • 8
  • 17
mabreu0
  • 80
  • 2
  • 8
  • How does your root entity look like? does it have any properties apart from the id? Does the error go away if you add a "name" for example? Either way this looks like a bug to me. Could you create a bug report with a reproducer at https://github.com/spring-projects/spring-data-relational/issues – Jens Schauder Mar 23 '22 at 07:38
  • 1
    Sir @JensSchauder Thanks a lot for taking the moment. Surely not a framework issue. I was missing the idea of having a primary key in the value object (the lookup table) apart from the foreign key to actual entity. Messing the MappedCollection relation. – mabreu0 Mar 25 '22 at 21:16

1 Answers1

0

Take a look at the foreign table primary key. Even though not strictly necessary to be in consistent state. Anyways, one of the statement of 3NF is that all records in a table must be uniquely identified not matter if they don't represent an entity perse. Data-jdbc uses this key for the relations with List, Set, Map.

https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#jdbc.entity-persistence.types

mabreu0
  • 80
  • 2
  • 8