-
Notifications
You must be signed in to change notification settings - Fork 364
Closed
Labels
Milestone
Description
Andrew Thorburn opened DATAJDBC-273 and commented
Given an entity definition like (in Kotlin), full code at the reference URL:
data class Application(
@Id
val applicationId: Int,
val applicationState: String,
@Column(value = "APPLICATION_ID", keyColumn = "APPLICANT_ORDER")
var applicants: List<Applicant>
)
data class Applicant(...)
Attempting to load that entity gives the following partial exception:
2018-10-12 14:51:58.314 ERROR 58488 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.mapping.MappingException: Could not read value applicants_APPLICATION_ID from result set!] with root cause
org.hsqldb.HsqlException: Column not found: applicants_applicant_id
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.4.1.jar:2.4.1]
at org.hsqldb.error.Error.error(Unknown Source) ~[hsqldb-2.4.1.jar:2.4.1]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) ~[hsqldb-2.4.1.jar:2.4.1]
at org.hsqldb.jdbc.JDBCResultSet.findColumn(Unknown Source) ~[hsqldb-2.4.1.jar:2.4.1]
at org.hsqldb.jdbc.JDBCResultSet.getObject(Unknown Source) ~[hsqldb-2.4.1.jar:2.4.1]
at org.springframework.data.jdbc.core.EntityRowMapper.getObjectFromResultSet(EntityRowMapper.java:164) ~[spring-data-jdbc-1.1.0.DATAJDBC-271-SNAPSHOT.jar:1.1.0.DATAJDBC-271-SNAPSHOT]
at org.springframework.data.jdbc.core.EntityRowMapper.readFrom(EntityRowMapper.java:126) ~[spring-data-jdbc-1.1.0.DATAJDBC-271-SNAPSHOT.jar:1.1.0.DATAJDBC-271-SNAPSHOT]
at org.springframework.data.jdbc.core.EntityRowMapper.readEntityFrom(EntityRowMapper.java:143) ~[spring-data-jdbc-1.1.0.DATAJDBC-271-SNAPSHOT.jar:1.1.0.DATAJDBC-271-SNAPSHOT]
at org.springframework.data.jdbc.core.EntityRowMapper.readFrom(EntityRowMapper.java:123) ~[spring-data-jdbc-1.1.0.DATAJDBC-271-SNAPSHOT.jar:1.1.0.DATAJDBC-271-SNAPSHOT]
at org.springframework.data.jdbc.core.EntityRowMapper.lambda$createInstance$0(EntityRowMapper.java:179) ~[spring-data-jdbc-1.1.0.DATAJDBC-271-SNAPSHOT.jar:1.1.0.DATAJDBC-271-SNAPSHOT]
Per Mark Paluch, the cause is this:
It’s a bug in Spring Data JDBC related to constructor creation
So all the poking around the embedded
@Id
wasn’t really the causeFor Kotlin data classes, we attempt to create the entity using its constructor and in that code path we have a bug that assumes the applicant is a nested entity.
Affects: 1.0 GA (Lovelace)
Reference URL: https://github.com/ipsi/spring-data-jdbc-playground
Referenced from: pull request #96, and commits aec5722, 9fb5aad, baeb8d8
1 votes, 2 watchers