Skip to content

Commit 15c2a5a

Browse files
adding example of JPA Entities
1 parent 52f1362 commit 15c2a5a

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package guru.springframework.spring6webapp.domain;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
8+
/**
9+
* Created by jt, Spring Framework Guru.
10+
*/
11+
@Entity
12+
public class Author {
13+
14+
@Id
15+
@GeneratedValue(strategy = GenerationType.AUTO)
16+
private Long id;
17+
private String firstName;
18+
private String lastName;
19+
20+
public Long getId() {
21+
return id;
22+
}
23+
24+
public void setId(Long id) {
25+
this.id = id;
26+
}
27+
28+
public String getFirstName() {
29+
return firstName;
30+
}
31+
32+
public void setFirstName(String firstName) {
33+
this.firstName = firstName;
34+
}
35+
36+
public String getLastName() {
37+
return lastName;
38+
}
39+
40+
public void setLastName(String lastName) {
41+
this.lastName = lastName;
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package guru.springframework.spring6webapp.domain;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
8+
/**
9+
* Created by jt, Spring Framework Guru.
10+
*/
11+
@Entity
12+
public class Book {
13+
14+
@Id
15+
@GeneratedValue(strategy = GenerationType.AUTO)
16+
private Long id;
17+
private String title;
18+
private String isbn;
19+
20+
public Long getId() {
21+
return id;
22+
}
23+
24+
public void setId(Long id) {
25+
this.id = id;
26+
}
27+
28+
public String getTitle() {
29+
return title;
30+
}
31+
32+
public void setTitle(String title) {
33+
this.title = title;
34+
}
35+
36+
public String getIsbn() {
37+
return isbn;
38+
}
39+
40+
public void setIsbn(String isbn) {
41+
this.isbn = isbn;
42+
}
43+
}

0 commit comments

Comments
 (0)