【发布时间】:2020-03-06 03:53:36
【问题描述】:
Entity 的属性之一是inline class(在提出此问题时是一个实验性功能)。在运行 Spring Boot 应用程序时,我收到了 java.lang.ArrayIndexOutOfBoundsException: 3,这对我来说毫无意义。
原来3 是表示属性在我的实体中的位置的数字。
@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)
这是堆栈跟踪的一部分:
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)
...
【问题讨论】:
标签: jpa kotlin spring-data-jpa