使用JPA + Kotlin收集映射错误

我试图使用这两个实体之间的多对多关系。

@Entity data class Course( @Id @GeneratedValue var id: Long = 0, var name: String, var lectures: Int, @JsonIgnore @JoinTable(name = "CourseStudent", joinColumns = arrayOf(JoinColumn(name = "courseId", referencedColumnName = "id")), inverseJoinColumns = arrayOf(JoinColumn(name = "studentId", referencedColumnName = "id")) ) val enrolled: List = emptyList() ) @Entity data class User( @Id @GeneratedValue var id: Long = 0, var username: String, var password: String, @ManyToMany(mappedBy = "enrolled") val courses: List = emptyList() ) 

但我总是得到这个例外:

org.springframework.beans.factory.BeanCreationException:创建在类路径资源[org / springframework / boot / autoconfigure / orm / jpa / HibernateJpaConfiguration.class]中定义名称为’entityManagerFactory’的bean时出错:init方法的调用失败; 嵌套exception是javax.persistence.PersistenceException:[PersistenceUnit:default]无法在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1710)〜[spring-beans-5.0.2。]上构建Hibernate SessionFactory。 RELEASE.jar:5.0.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583)〜[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE ]在org.springframework.beans.factory的org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:502)〜[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE] .support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:312)〜[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton (DefaultSingletonBeanRegistry.java:228)〜[spring-beans-5.0.2.RELE ASE.jar:5.0.2.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)〜[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE ]在org.springframework.context.support的org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200)〜[spring-beans-5.0.2.RELEASE.jar:5.0.2.RELEASE] .AbstractApplicationContext.getBean(AbstractApplicationContext.java:1085)〜[spring-context-5.0.2.RELEASE.jar:5.0.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:858) 〜[spring-context-5.0.2.RELEASE.jar:5.0.2.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)〜[spring-context-5.0.2.RELEASE .jar:5.0.2.RELEASE]在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138)〜[spring-boot-2.0.0.M7.jar:2。 在org.springframework.boot.SpringApplication.refreshContext上的org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751)[spring-boot-2.0.0.M7.jar:2.0.0.M7] (SpringApplication.java:387)[spring-boot-2.0.0.M7.jar:2.0.0.M7] at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)[spring-boot-2.0。 org.springframework.boot.SpringApplication.run(SpringApplication.java:1245)[spring-boot-2.0.0.M7.jar:2.0.0.M7]在org中的[0.M7.jar:2.0.0.M7] .springframework.boot.SpringApplication.run(SpringApplication.java:1233)[spring-boot-2.0.0.M7.jar:2.0.0.M7] at com.authentication.auth.AuthApplicationKt.main(AuthApplication.kt:25 )[classes /:na]导致:javax.persistence.PersistenceException:[PersistenceUnit:default]无法在org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:967)〜[hibernate]上构建Hibernate SessionFactory -core-5.2.12.Final.jar:5.2.12.Final] at org.hibernate.jpa。 boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final] at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider .java:57)〜[spring-orm-5.0.2.RELEASE.jar:5.0.2.RELEASE] at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)〜[spring-orm- 5.0.2.RELEASE.jar:5.0.2.RELEASE]在org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:387)〜[spring-orm-5.0.2.RELEASE.jar:5.0.2 .RELEASE]在org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:376)〜[spring-orm-5.0.2.RELEASE.jar:5.0.2.RELEASE] .LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalCont ainerEntityManagerFactoryBean.java:341)〜[spring-orm-5.0.2.RELEASE.jar:5.0.2.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1769)〜[spring -beans-5.0.2.RELEASE.jar:5.0.2.RELEASE]在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706)〜[spring-beans-5.0.2.RELEASE。 jar:5.0.2.RELEASE] … 16个常见的框架遗漏引起:org.hibernate.MappingException:无法确定types:java.util.List,在表:课程,为列:[org.hibernate.mapping .column(注册)]在org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:455)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final] at org.hibernate.mapping。 SimpleValue.isValid(SimpleValue.java:422)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final] at org.hibernate.mapping.Property.isValid(Property.java:226)〜[hibernate -core-5.2.12.Final.jar:5.2.12.Final] at o rg.hibernate.mapping.PersistentClass.validate(PersistentClass.java:597)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final] at org.hibernate.mapping.RootClass.validate(RootClass.java :265)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final] at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:329)〜[hibernate-core-5.2。 12.Final.jar:5.2.12.Final]在org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:451)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final ]在org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)〜[hibernate-core-5.2.12.Final.jar:5.2.12.Final] … 23个常用的框架

我已经 :
试图从类声明中删除“data”关键字
– 试图声明这样的字段:MutableList = mutableListOf()
– 试过有没有“referencedColumnName”属性

我目前正在使用hsqldb

Kotlin language will be the best programming language for Android.