8000 create data model · prog012/java-design-patterns@ca73621 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit ca73621

Browse files
committed
create data model
1 parent 4e99888 commit ca73621

File tree

2 files changed

+122
-0
lines changed

2 files changed

+122
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.iluwatar.cqrs.domain.model;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.GenerationType;
6+
import javax.persistence.Id;
7+
8+
/**
9+
*
10+
* @author Sabiq Ihab
11+
*
12+
*/
13+
@Entity
14+
public class Author {
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
private long id;
18+
private String username;
19+
private String name;
20+
private String email;
21+
22+
/**
23+
*
24+
* @param username
25+
* @param name
26+
* @param email
27+
*/
28+
public Author(String username, String name, String email) {
29+
super();
30+
this.username = username;
31+
this.name = name;
32+
this.email = email;
33+
}
34+
35+
public Author() {
36+
super();
37+
}
38+
39+
public long getId() {
40+
return id;
41+
}
42+
43+
public String getUsername() {
44+
return username;
45+
}
46+
47+
public String getName() {
48+
return name;
49+
}
50+
51+
public String getEmail() {
52+
return email;
53+
}
54+
55+
@Override
56+
public String toString() {
57+
return "Author [name=" + name + ", email=" + email + "]";
58+
}
59+
60+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package com.iluwatar.cqrs.domain.model;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.GenerationType;
6+
import javax.persistence.Id;
7+
import javax.persistence.ManyToOne;
8+
9+
/**
10+
*
11+
* @author Sabiq Ihab
12+
*
13+
*/
14+
@Entity
15+
public class Book {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.IDENTITY)
18+
private long id;
19+
private String title;
20+
private double price;
21+
@ManyToOne
22+
private Author author;
23+
24+
/**
25+
*
26+
* @param title
27+
* @param price
28+
* @param author
29+
*/
30+
public Book(String title, double price, Author author) {
31+
super();
32+
this.title = title;
33+
this.price = price;
34+
this.author = author;
35+
}
36+
37+
public Book() {
38+
super();
39+
}
40+
41+
public long getId() {
42+
return id;
43+
}
44+
45+
public String getTitle() {
46+
return title;
47+
}
48+
49+
public double getPrice() {
50+
return price;
51+
}
52+
53+
public Author getAuthor() {
54+
return author;
55+
}
56+
57+
@Override
58+
public String toString() {
59+
return "Book [title=" + title + ", price=" + price + ", author=" + author + "]";
60+
}
61+
62+
}

0 commit comments

Comments
 (0)
0