Zizalik

CurrencyDatabaseTable

May 16th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1.  
  2. package DB;
  3.  
  4. import java.io.Serializable;
  5. import java.util.List;
  6. import javax.persistence.CascadeType;
  7. import javax.persistence.Column;
  8. import javax.persistence.Entity;
  9. import javax.persistence.GeneratedValue;
  10. import javax.persistence.GenerationType;
  11. import javax.persistence.Id;
  12. import javax.persistence.OneToMany;
  13. import javax.persistence.Table;
  14.  
  15. @Entity
  16. @Table(name = "Country")
  17. public class Country implements Serializable {
  18. @Id
  19. @GeneratedValue(strategy = GenerationType.IDENTITY)
  20. @Column(name="id")
  21. private int id;
  22.  
  23. @Column(name="Name", nullable = false, length = 50)
  24. private String name;
  25.  
  26. @Column(name="Continent", nullable = true, length = 20)
  27. private String continent;
  28.  
  29. @OneToMany(mappedBy = "country", cascade=CascadeType.ALL)
  30. private List<Currency> currencies;
  31.  
  32. public Country() {
  33. }
  34.  
  35. public Country(String name, String continent, List<Currency> actors) {
  36. this.name = name;
  37. this.continent = continent;
  38. this.currencies = actors;
  39. }
  40.  
  41.  
  42.  
  43.  
  44. public String getName() {
  45. return name;
  46. }
  47.  
  48. public void setName(String name) {
  49. this.name = name;
  50. }
  51.  
  52.  
  53. public List<Currency> getCurrencies() {
  54. return currencies;
  55. }
  56.  
  57. public void setCurrencies(List<Currency> currencies) {
  58. this.currencies = currencies;
  59. }
  60.  
  61.  
  62. public int getId() {
  63. return id;
  64. }
  65.  
  66. public void setId(int id) {
  67. this.id = id;
  68. }
  69.  
  70. public String getContinent() {
  71. return continent;
  72. }
  73.  
  74. public void setContinent(String continent) {
  75. this.continent = continent;
  76. }
  77.  
  78. @Override
  79. public String toString() {
  80.  
  81. return "\n\nCountry: \n id=" + id + "\n Name: " + name
  82. + "\n Continent: " + continent + "\n Currencies: " + currencies;
  83. }
  84. }
Add Comment
Please, Sign In to add comment