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
I'm working in a project using Kotlin and JDBC for our service and I'm seeing the following exception when trying to save an object to the database:
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at org.springframework.data.mapping.model.KotlinCopyMethod.shouldUsePublicCopyMethod(KotlinCopyMethod.java:177)
We're trying to save an aggregate that looks something like this:
@Table("some_aggregate")
data class SomeAggregate(
@Id
var id: UUID? = null,
@MappedCollection(idColumn = "objectId")
val objects: Set<SomeRelatedObject> = emptySet(),
)
@Table("some_related_object")
data class SomeRelatedObject(
val relatedObject: AggregateReference<ObjectAggregate, UUID>,
)
The problem is with the SomeRelatedObject data class, since this has an empty persistentProperties, resulting from relatedObject being an Association. Therefore when iterating over parameterTypes, it throws the IndexOutOfBoundsException.
The text was updated successfully, but these errors were encountered:
odrotbohm
changed the title
IndexOutOfBoundsException on KotlinCopyMethod.shouldUsePublicCopyMethod when saving Kotlin data class with Association in JDBCIndexOutOfBoundsException on KotlinCopyMethod.shouldUsePublicCopyMethod(…) when saving Kotlin data class with Association in JDBC
Aug 5, 2024
mp911de
changed the title
IndexOutOfBoundsException on KotlinCopyMethod.shouldUsePublicCopyMethod(…) when saving Kotlin data class with Association in JDBCIndexOutOfBoundsException on KotlinCopyMethod.shouldUsePublicCopyMethod(…) when saving single-property Kotlin data class with Association
Aug 6, 2024
KotlinCopyMethod.shouldUsePublicCopyMethod(…) now considers single-association arrangements. Also, the method now early exists if pre-conditions aren't met.
Closes#3131
KotlinCopyMethod.shouldUsePublicCopyMethod(…) now considers single-association arrangements. Also, the method now early exists if pre-conditions aren't met.
Closes#3131
I'm working in a project using Kotlin and JDBC for our service and I'm seeing the following exception when trying to save an object to the database:
We're trying to save an aggregate that looks something like this:
The problem is with the SomeRelatedObject data class, since this has an empty persistentProperties, resulting from relatedObject being an Association. Therefore when iterating over parameterTypes, it throws the IndexOutOfBoundsException.
The text was updated successfully, but these errors were encountered: