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
importorg.springframework.data.annotation.Idimportorg.springframework.data.relational.core.mapping.Table
@Table("TEST_SIMPLE_TABLE")
data classSimpleTable(
@Id
varsimpleId:Int,
varname:String
)
val simpleTable =SimpleTable(simpleId =0, name ="something")
jdbcAggregateTemplate.insert(entity)
this generates SQL without SIMPLE_ID column and obviously fails:
INSERT INTO "TEST_SIMPLE_TABLE" ("NAME") VALUES ('something')
java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ("TEST_SIMPLE_TABLE"."SIMPLE_ID")
it is related with Kotlin's Int bytecode mapping (Int -> int, Int? -> java.lang.Integer)
when simpleId is set to other value than 0, it works
when simpleId is defined as Int? , it works
so Int? is workaround, but not ideal to loose nullability check.
Looks like bug to me.
The text was updated successfully, but these errors were encountered:
You are correct, just one clarification - JdbcAggregateTemplate#insert does not help, it is actually what I tried and described above. So entity change detection also does not help, because I am already doing insert.
Thanks for the info anyway :)
Kotlin 2.1.0
spring-boot-starter-data-jdbc 3.4.0
this generates SQL without SIMPLE_ID column and obviously fails:
it is related with Kotlin's Int bytecode mapping (Int -> int, Int? -> java.lang.Integer)
simpleId
is set to other value than 0, it workssimpleId
is defined asInt?
, it worksso Int? is workaround, but not ideal to loose nullability check.
Looks like bug to me.
The text was updated successfully, but these errors were encountered: