我试图在Kotlin建立多对多关系,具体如下:
@Entity
data class Gender(@field:Id var abbr: Char? = null,
var description: String = "") : PanacheEntityBase
@Entity
data class Interest(
var description: String = ""): PanacheEntity()
@Entity
data class User(@field:Id var id: UUID? = null,
@ManyToOne(fetch = FetchType.LAZY) var gender: Gender? = null,
var birthday: Long = 0,
@ManyToMany(fetch = FetchType.LAZY, cascade = [CascadeType.PERSIST])
@JoinTable(
name = "user_interests",
joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")],
inverseJoinColumns = [JoinColumn(name = "interest_id", referencedColumnName = "id")]
)
var interests: List<Interest> = listOf()) : PanacheEntityBase
我收到错误信息:
GenerationTarget encountered exception accepting command : Error executing DDL "drop table if exists User cascade" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table if exists User cascade" via JDBC Statement
Error executing DDL "create table User (id uuid not null, birthday int8 not null, gender_abbr char(1), primary key (id))" via JDBC Statement: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "create table User (id uuid not null, birthday int8 not null, gender_abbr char(1), primary key (id))" via JDBC Statement
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "User"
Position: 22
我做错什么了?
暂无答案!
目前还没有任何答案,快来回答吧!