3
3
import jakarta .persistence .Column ;
4
4
import jakarta .persistence .FetchType ;
5
5
import jakarta .persistence .Id ;
6
- import jakarta .persistence .IdClass ;
7
6
import jakarta .persistence .JoinColumn ;
8
7
import jakarta .persistence .ManyToOne ;
9
8
import java .io .Serializable ;
10
9
import java .util .Objects ;
11
10
12
- @ IdClass (PostTextPK .class )
13
11
public class PostTextPK implements Serializable {
14
12
15
- @ ManyToOne ( fetch = FetchType . LAZY )
16
- @ JoinColumn (name = "post" , referencedColumnName = "id " , nullable = false )
17
- public Post post ;
13
+ @ Id
14
+ @ Column (name = "post" , nullable = false )
15
+ private int postId ;
18
16
19
17
@ Id
20
18
@ Column (name = "language" , nullable = false , length = -1 )
21
19
private String language ;
22
20
23
- public Post getPost () {
24
- return post ;
21
+ public int getPostId () {
22
+ return postId ;
25
23
}
26
24
27
- public void setPost ( Post post ) {
28
- this .post = post ;
25
+ public void setPostId ( int postId ) {
26
+ this .postId = postId ;
29
27
}
30
28
31
29
public String getLanguage () {
@@ -45,11 +43,11 @@ public boolean equals(Object o) {
45
43
return false ;
46
44
}
47
45
PostTextPK that = (PostTextPK ) o ;
48
- return Objects .equals (getPost (), that .getPost ()) && getLanguage ().equals (that .getLanguage ());
46
+ return Objects .equals (getPostId (), that .getPostId ()) && getLanguage ().equals (that .getLanguage ());
49
47
}
50
48
51
49
@ Override
52
50
public int hashCode () {
53
- return Objects .hash (getPost (), getLanguage ());
51
+ return Objects .hash (getPostId (), getLanguage ());
54
52
}
55
53
}
0 commit comments