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.