日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java collection join_java – @ElementCollection @CollectionTable在一对多映射中

發布時間:2024/10/8 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java collection join_java – @ElementCollection @CollectionTable在一对多映射中 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我在使用嵌入式注釋的JPA中嘗試關系,但我無法成功運行它,

這里我的數據庫sql腳本如下,

create table TBL_COLLEGE(

id integer primary key generated always as identity (start with 1000, increment by 5),

name varchar(50)

)

create table TBL_COURSE(

Id integer primary key generated always as identity (start with 10, increment by 1),

college_Id integer references TBL_COLLEGE,

name varchar(50)

)

以下是JPA的代碼,

@Embeddable

public class Course {

...

...

..

@Id

@GeneratedValue(strategy= GenerationType.IDENTITY)

@Column(name="ID")

private Integer courseId;

@Column(name="NAME")

private String courseName;

@Column(name="COLLEGE_ID")

private Integer collegeId;

....

// getter and setter

}

這是學院的地圖,

@Entity

@Table(name="TBL_COLLEGE")

public class College implements Serializable{

@Id

@GeneratedValue(strategy= GenerationType.IDENTITY)

@Column(name="ID")

private Integer collegeId;

...

..

@ElementCollection(targetClass=Course.class,fetch= FetchType.LAZY)

@CollectionTable(name="TBL_COURSE",joinColumns=@JoinColumn(name="COLLEGE_ID"))

private Set course;

..

// getter and setter

}

但是,如果我嘗試堅持學院與課程集合,

它給了我一個例外,

ERROR: HCANN000002: An assertion failure occurred (this may indicate a bug in Hibernate)

org.hibernate.annotations.common.AssertionFailure: Declaring class is not found in the inheritance state hierarchy: com.entities.Course

....

..

你能告訴我我的做法是否錯誤,

或者我對@CollectionTable的理解仍然很少,

我錯了

總結

以上是生活随笔為你收集整理的java collection join_java – @ElementCollection @CollectionTable在一对多映射中的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。