You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reading from the TicketRepository I got the warning WARN 4594 — [ main] o.s.d.j.core.convert.ResultSetAccessor : ResultSet contains ID multiple times.
I also noticed that the ID field is two times present in the query: DEBUG 4594 — [ main] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT "TICKET"."ID" AS "ID", "TICKET"."ID" AS "ID", "TICKET"."TITLE" AS "TITLE" FROM "TICKET" WHERE "TICKET"."ID" = ?]
Is it possible to use base entities? I did not noticed this warning in spring-data-jdbc 1.1.5.RELEASE (but also the duplicate ID in the SELECT statement).
I haven't looked into the example project to determine what is going on.
Spring Data JDBC doesn't care about inheritance. It just analyses the class at hand and works with whatever it finds.
Why it seems to find two id properties is currently not clear to me.
I'll have to investigate that.
The warning really just tells you that the query result is weird, because it doesn't have a single column per field, but multiple columns. As long as both columns contain the same value and the JDBC driver doesn't complain everything should be fine
It looks like the ID property gets found twice, probably once in the base class and once in the inherited class.
In the select this leads to selecting it twice. On insert it leads to including it in the insert, which shouldn't happen, since the id is null and therefore should not be written to the database and instead be generated and returned by the database.
It removes overridden properties only when the type is not assignable.
This is not the case her.
What we have here is another variant for which the mentioned issue actually adds documentation:
Overriding actually creates two fields, which are both visible to Spring Data JDBC and therefore both get persisted, leading to the problems you are seeing.
To resolve this, mark the property in the base class with @Transient and move the @Id annotation and any other annotations to the sub class, like this:
Clemens Hahn opened DATAJDBC-579 and commented
I'm working with an abstract base entity model
My concrete model extends this base entity like
When reading from the
TicketRepository
I got the warningWARN 4594 — [ main] o.s.d.j.core.convert.ResultSetAccessor : ResultSet contains ID multiple times
.I also noticed that the ID field is two times present in the query:
DEBUG 4594 — [ main] o.s.jdbc.core.JdbcTemplate : Executing prepared SQL statement [SELECT "TICKET"."ID" AS "ID", "TICKET"."ID" AS "ID", "TICKET"."TITLE" AS "TITLE" FROM "TICKET" WHERE "TICKET"."ID" = ?]
Is it possible to use base entities? I did not noticed this warning in spring-data-jdbc 1.1.5.RELEASE (but also the duplicate ID in the SELECT statement).
Please feel free to use my showcase in order to reproduce this scenario at GitHub (
ticket/DATAJDBC-579
branch)Affects: 2.1 M1 (2020.0.0)
The text was updated successfully, but these errors were encountered: