Hibernate:集合是用原始类型声明的,并且有一个显式的'targetEntity'

hof1towb  于 2023-11-21  发布在  其他
关注(0)|答案(1)|浏览(223)

我在Kotlinvert.x项目中使用Hibernate reactive,当我尝试构建时,我得到以下错误:Collection 'com.chaluchukwu.drone_system.entities.Delivery.cargoes' is declared with a raw type and has an explicit 'targetEntity'下面是我的Delivery实体类:

@jakarta.persistence.Entity(name = "deliveries")
@Table(name = "deliveries")
open class Delivery(
  @Column(name = "user_name")
  open var userName: String? = null,

  @Column(name= "reference")
  open var reference: String? = UUID.randomUUID().toString().substring(0,10),

  @ManyToOne
  open var drone: Drone? = null,

  @OneToMany
  open var cargoes: List<Cargo>? = listOf(),

  @CreationTimestamp(source = SourceType.DB)
  @Column(name = "created_at")
  open var createdAt: Date? = null,

  @UpdateTimestamp(source = SourceType.DB)
  @Column(name = "updated_at")
  open var updatedAt: Date? = null,

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  open var id: Long? = null
  ) {}

字符串
有什么问题吗??

xxls0lw8

xxls0lw81#

Delivery类中,为@OneToMany注解指定targetEntity属性,以消除任何歧义,并让Hibernate确定集合中元素的目标实体类型。

@OneToMany(targetEntity = Cargo::class)
open var cargoes: List<Cargo>? = listOf()

字符串

相关问题