4
4
import java .util .HashSet ;
5
5
import java .util .Map ;
6
6
import java .util .Set ;
7
+
7
8
import javax .persistence .AttributeOverride ;
8
9
import javax .persistence .AttributeOverrides ;
9
10
import javax .persistence .CollectionTable ;
@@ -34,16 +35,16 @@ public class Boy {
34
35
private Integer id ;
35
36
private String firstName ;
36
37
private String lastName ;
37
- // private Set<String> nickNames = new HashSet<String>();
38
- // private Set<String> hatedNames = new HashSet<String>();
39
- // private Set<String> preferredNames = new HashSet<String>();
40
- // private Map<String, Integer> scorePerNickName = new HashMap<String, Integer>();
41
- // private Map<String, Integer> scorePerPreferredName = new HashMap<String, Integer>();
42
- // private int[] favoriteNumbers;
38
+ private Set <String > nickNames = new HashSet <String >();
39
+ private Set <String > hatedNames = new HashSet <String >();
40
+ private Set <String > preferredNames = new HashSet <String >();
41
+ private Map <String , Integer > scorePerNickName = new HashMap <String , Integer >();
42
+ private Map <String , Integer > scorePerPreferredName = new HashMap <String , Integer >();
43
+ private int [] favoriteNumbers ;
43
44
private Set <Toy > favoriteToys = new HashSet <Toy >();
44
- // private Set<Character> characters = new HashSet<Character>();
45
- // private Map<String, FavoriteFood> foods = new HashMap<String,FavoriteFood>();
46
- // private Set<CountryAttitude> countryAttitudes = new HashSet<CountryAttitude>();
45
+ private Set <Character > characters = new HashSet <Character >();
46
+ private Map <String , FavoriteFood > foods = new HashMap <String ,FavoriteFood >();
47
+ private Set <CountryAttitude > countryAttitudes = new HashSet <CountryAttitude >();
47
48
48
49
@ Id
49
50
@ GeneratedValue
@@ -71,70 +72,70 @@ public void setLastName(String lastName) {
71
72
this .lastName = lastName ;
72
73
}
73
74
74
- // @ElementCollection
75
- // public Set<String> getNickNames() {
76
- // return nickNames;
77
- // }
78
- //
79
- // public void setNickNames(Set<String> nickName) {
80
- // this.nickNames = nickName;
81
- // }
82
- //
83
- // @ElementCollection //default column names
84
- // public Set<String> getHatedNames() {
85
- // return hatedNames;
86
- // }
87
- //
88
- // public void setHatedNames(Set<String> hatedNames) {
89
- // this.hatedNames = hatedNames;
90
- // }
91
- //
92
- // @ElementCollection //default column names
93
- // @Column
94
- // public Set<String> getPreferredNames() {
95
- // return preferredNames;
96
- // }
97
- //
98
- // public void setPreferredNames(Set<String> preferredNames) {
99
- // this.preferredNames = preferredNames;
100
- // }
101
- //
102
- // @ElementCollection
103
- // @MapKeyColumn(nullable=false)
104
- // public Map<String, Integer> getScorePerPreferredName() {
105
- // return scorePerPreferredName;
106
- // }
107
- //
108
- // public void setScorePerPreferredName(Map<String, Integer> scorePerPreferredName) {
109
- // this.scorePerPreferredName = scorePerPreferredName;
110
- // }
111
- //
112
- // @ElementCollection
113
- // @CollectionTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId"))
114
- // @Column(name = "score", nullable = false)
115
- // @MapKeyColumn(nullable=false)
116
- // public Map<String, Integer> getScorePerNickName() {
117
- // return scorePerNickName;
118
- // }
119
- //
120
- // public void setScorePerNickName(Map<String, Integer> scorePerNickName) {
121
- // this.scorePerNickName = scorePerNickName;
122
- // }
123
- //
124
- // @ElementCollection
125
- // @CollectionTable(
126
- // name = "BoyFavoriteNumbers",
127
- // joinColumns = @JoinColumn(name = "BoyId")
128
- // )
129
- // @Column(name = "favoriteNumber", nullable = false)
130
- // @OrderColumn(name = "nbr_index")
131
- // public int[] getFavoriteNumbers() {
132
- // return favoriteNumbers;
133
- // }
134
- //
135
- // public void setFavoriteNumbers(int[] favoriteNumbers) {
136
- // this.favoriteNumbers = favoriteNumbers;
137
- // }
75
+ @ ElementCollection
76
+ public Set <String > getNickNames () {
77
+ return nickNames ;
78
+ }
79
+
80
+ public void setNickNames (Set <String > nickName ) {
81
+ this .nickNames = nickName ;
82
+ }
83
+
84
+ @ ElementCollection //default column names
85
+ public Set <String > getHatedNames () {
86
+ return hatedNames ;
87
+ }
88
+
89
+ public void setHatedNames (Set <String > hatedNames ) {
90
+ this .hatedNames = hatedNames ;
91
+ }
92
+
93
+ @ ElementCollection //default column names
94
+ @ Column
95
+ public Set <String > getPreferredNames () {
96
+ return preferredNames ;
97
+ }
98
+
99
+ public void setPreferredNames (Set <String > preferredNames ) {
100
+ this .preferredNames = preferredNames ;
101
+ }
102
+
103
+ @ ElementCollection
104
+ @ MapKeyColumn (nullable =false )
105
+ public Map <String , Integer > getScorePerPreferredName () {
106
+ return scorePerPreferredName ;
107
+ }
108
+
109
+ public void setScorePerPreferredName (Map <String , Integer > scorePerPreferredName ) {
110
+ this .scorePerPreferredName = scorePerPreferredName ;
111
+ }
112
+
113
+ @ ElementCollection
114
+ @ CollectionTable (name = "ScorePerNickName" , joinColumns = @ JoinColumn (name = "BoyId" ))
115
+ @ Column (name = "score" , nullable = false )
116
+ @ MapKeyColumn (nullable =false )
117
+ public Map <String , Integer > getScorePerNickName () {
118
+ return scorePerNickName ;
119
+ }
120
+
121
+ public void setScorePerNickName (Map <String , Integer > scorePerNickName ) {
122
+ this .scorePerNickName = scorePerNickName ;
123
+ }
124
+
125
+ @ ElementCollection
126
+ @ CollectionTable (
127
+ name = "BoyFavoriteNumbers" ,
128
+ joinColumns = @ JoinColumn (name = "BoyId" )
129
+ )
130
+ @ Column (name = "favoriteNumber" , nullable = false )
131
+ @ OrderColumn (name = "nbr_index" )
132
+ public int [] getFavoriteNumbers () {
133
+ return favoriteNumbers ;
134
+ }
135
+
136
+ public void setFavoriteNumbers (int [] favoriteNumbers ) {
137
+ this .favoriteNumbers = favoriteNumbers ;
138
+ }
138
139
@ ElementCollection
139
140
@ AttributeOverride (name = "element.serial" , column = @ Column (name = "serial_nbr" ))
140
141
public Set <Toy > getFavoriteToys () {
@@ -145,36 +146,36 @@ public void setFavoriteToys(Set<Toy> favoriteToys) {
145
146
this .favoriteToys = favoriteToys ;
146
147
}
147
148
148
- // @ElementCollection
149
- // @Enumerated(EnumType.STRING)
150
- // @Column(name = "`characters`")
151
- // public Set<Character> getCharacters() {
152
- // return characters;
153
- // }
154
- //
155
- // public void setCharacters(Set<Character> characters) {
156
- // this.characters = characters;
157
- // }
158
- //
159
- // @ElementCollection
160
- // @Enumerated(EnumType.STRING)
161
- // @MapKeyColumn(nullable=false)
162
- // public Map<String, FavoriteFood> getFavoriteFood() {
163
- // return foods;
164
- // }
165
- //
166
- // public void setFavoriteFood(Map<String, FavoriteFood>foods) {
167
- // this.foods = foods;
168
- // }
169
- //
170
- // @ElementCollection(fetch = FetchType.EAGER)
171
- // //@Where(clause = "b_likes=false")
172
- // public Set<CountryAttitude> getCountryAttitudes() {
173
- // return countryAttitudes;
174
- // }
175
- //
176
- // public void setCountryAttitudes(Set<CountryAttitude> countryAttitudes) {
177
- // this.countryAttitudes = countryAttitudes;
178
- // }
149
+ @ ElementCollection
150
+ @ Enumerated (EnumType .STRING )
151
+ @ Column (name = "`characters`" )
152
+ public Set <Character > getCharacters () {
153
+ return characters ;
154
+ }
155
+
156
+ public void setCharacters (Set <Character > characters ) {
157
+ this .characters = characters ;
158
+ }
159
+
160
+ @ ElementCollection
161
+ @ Enumerated (EnumType .STRING )
162
+ @ MapKeyColumn (nullable =false )
163
+ public Map <String , FavoriteFood > getFavoriteFood () {
164
+ return foods ;
165
+ }
166
+
167
+ public void setFavoriteFood (Map <String , FavoriteFood >foods ) {
168
+ this .foods = foods ;
169
+ }
170
+
171
+ @ ElementCollection (fetch = FetchType .EAGER )
172
+ //@Where(clause = "b_likes=false")
173
+ public Set <CountryAttitude > getCountryAttitudes () {
174
+ return countryAttitudes ;
175
+ }
176
+
177
+ public void setCountryAttitudes (Set <CountryAttitude > countryAttitudes ) {
178
+ this .countryAttitudes = countryAttitudes ;
179
+ }
179
180
}
180
181
0 commit comments