One of the attributes of an Entity
was an inline class
(an experimental feature at the time of this question). And when running a spring boot application I was getting a java.lang.ArrayIndexOutOfBoundsException: 3
which made no sense to me.
Turns out 3
was the number indicating the position of the attribute in my entity.
@Entity
@Table(name = "my_entity_table")
class MyEntity(
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long = 0,
@Column(name = "some_field")
val someField: Int = 2,
@Column(name = "a_second_field")
val aSecondField: ASecondField
)
inline class ASecondField(val value: String)
And this was part of the stacktrace:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myEntityRepository': Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 3
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
at org.springframework.data.mapping.model.PreferredConstructorDiscoverer$Discoverers.buildPreferredConstructor(PreferredConstructorDiscoverer.java:221)
at org.springframework.data.mapping.model.PreferredConstructorDiscoverer$Discoverers.access$200(PreferredConstructorDiscoverer.java:89)
at org.springframework.data.mapping.model.PreferredConstructorDiscoverer$Discoverers$2.lambda$discover$0(PreferredConstructorDiscoverer.java:161)
...