File tree Expand file tree Collapse file tree
spring-jpa/src/main/java/org/baeldung/persistence/model Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .baeldung .persistence .model ;
22
33import java .io .Serializable ;
4-
54import javax .persistence .Column ;
65import javax .persistence .Entity ;
76import javax .persistence .GeneratedValue ;
1211@ Entity
1312public class Bar implements Serializable {
1413
14+ private static final long serialVersionUID = 1L ;
15+
1516 @ Id
1617 @ GeneratedValue (strategy = GenerationType .AUTO )
17- private long id ;
18-
19- @ Column (nullable = false )
20- private String name ;
18+ private int id ;
2119
2220 @ OneToMany (mappedBy = "bar" , fetch = FetchType .EAGER , cascade = CascadeType .ALL )
2321 @ OrderBy ("name ASC" )
2422 List <Foo > fooList ;
2523
26- public Bar () {
24+ private String name ;
25+
26+ public Bar (){
2727 super ();
2828 }
2929
30- public Bar (final String name ) {
30+ public Bar (final String name ){
3131 super ();
32-
3332 this .name = name ;
3433 }
34+
35+ //API
3536
36- // API
37-
38- public long getId () {
39- return id ;
37+ public List <Foo > getFooList () {
38+ return fooList ;
4039 }
4140
42- public void setId ( final long id ) {
43- this .id = id ;
41+ public void setFooList ( List < Foo > fooList ) {
42+ this .fooList = fooList ;
4443 }
4544
46- public String getName () {
47- return name ;
45+ public int getId () {
46+ return this . id ;
4847 }
4948
50- public void setName ( final String name ) {
51- this .name = name ;
49+ public void setId ( int id ) {
50+ this .id = id ;
5251 }
5352
54- public List < Foo > getFooList () {
55- return fooList ;
53+ public String getName () {
54+ return this . name ;
5655 }
5756
58- public void setFooList ( final List < Foo > fooList ) {
59- this .fooList = fooList ;
57+ public void setName ( String name ) {
58+ this .name = name ;
6059 }
6160
6261 //
Original file line number Diff line number Diff line change 11package org .baeldung .persistence .model ;
22
33import java .io .Serializable ;
4-
54import javax .persistence .Column ;
65import javax .persistence .Entity ;
76import javax .persistence .GeneratedValue ;
You can’t perform that action at this time.
0 commit comments