create data model

This commit is contained in:
Sabiq Ihab 2017-06-20 21:34:49 +00:00
parent 4e9988877a
commit ca73621f4d
2 changed files with 122 additions and 0 deletions

View File

@ -0,0 +1,60 @@
package com.iluwatar.cqrs.domain.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
/**
*
* @author Sabiq Ihab
*
*/
@Entity
public class Author {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String username;
private String name;
private String email;
/**
*
* @param username
* @param name
* @param email
*/
public Author(String username, String name, String email) {
super();
this.username = username;
this.name = name;
this.email = email;
}
public Author() {
super();
}
public long getId() {
return id;
}
public String getUsername() {
return username;
}
public String getName() {
return name;
}
public String getEmail() {
return email;
}
@Override
public String toString() {
return "Author [name=" + name + ", email=" + email + "]";
}
}

View File

@ -0,0 +1,62 @@
package com.iluwatar.cqrs.domain.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
/**
*
* @author Sabiq Ihab
*
*/
@Entity
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String title;
private double price;
@ManyToOne
private Author author;
/**
*
* @param title
* @param price
* @param author
*/
public Book(String title, double price, Author author) {
super();
this.title = title;
this.price = price;
this.author = author;
}
public Book() {
super();
}
public long getId() {
return id;
}
public String getTitle() {
return title;
}
public double getPrice() {
return price;
}
public Author getAuthor() {
return author;
}
@Override
public String toString() {
return "Book [title=" + title + ", price=" + price + ", author=" + author + "]";
}
}