Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. package entities;
  2.  
  3.  
  4.  
  5. import jdk.internal.agent.Agent;
  6.  
  7. import javax.persistence.*;
  8. import java.sql.Timestamp;
  9. import java.util.Set;
  10.  
  11. import static entities.Records.QUERY_GET_ALL_RECORDS;
  12.  
  13.  
  14. @NamedQueries(value = {
  15. @NamedQuery(
  16. name = "Records.getRecordById",
  17. query = "select rec from Records rec where rec.id = :insertId"
  18. ),
  19. @NamedQuery(
  20. name = QUERY_GET_ALL_RECORDS,
  21. query = "select rec from Records rec")
  22. })
  23. @Entity
  24. @Table(name="records")
  25. public class Records {
  26.  
  27. public static final String QUERY_GET_ALL_RECORDS = "GET_ALL_RECORDS";
  28.  
  29. @Id
  30. @GeneratedValue(strategy = GenerationType.IDENTITY)
  31. @Column(name = "id")
  32. private int id;
  33. @Column(name = "name")
  34. private String name;
  35. @Column(name = "link")
  36. private String link;
  37. @Column(name = "price")
  38. private int price;
  39. @Column(name = "costs")
  40. private int costs;
  41. @Column(name = "discription")
  42. private String discription;
  43. @Column(name = "date")
  44. private Timestamp date;
  45. @Column(name = "actually")
  46. private boolean actually;
  47. @ManyToMany
  48. @JoinTable(name="record_agent",
  49. joinColumns = @JoinColumn(name="record_id", referencedColumnName="id"),
  50. inverseJoinColumns = @JoinColumn(name="agent_id", referencedColumnName="id")
  51. )
  52. private Set<Agent> agents;
  53.  
  54.  
  55.  
  56.  
  57. public Records(int id, String name, String link, int price, Timestamp date, Boolean actually, int costs, String discription, Set<Agent> agents) {
  58. this.id = id;
  59. this.name = name;
  60. this.link = link;
  61. this.price = price;
  62. this.date = date;
  63. this.actually = actually;
  64. this.costs = costs;
  65. this.discription = discription;
  66. this.agents = agents;
  67.  
  68. }
  69.  
  70. public Records() {
  71. }
  72.  
  73. /* @ManyToMany
  74. @JoinTable(
  75.  
  76. )
  77. private Set<Agents> agents;*/
  78.  
  79. public int getId() {
  80. return id;
  81. }
  82.  
  83. public void setId(int id) {
  84. this.id = id;
  85. }
  86.  
  87. public String getName() {
  88. return name;
  89. }
  90.  
  91. public void setName(String name) {
  92. this.name = name;
  93. }
  94.  
  95. public String getLink() {
  96. return link;
  97. }
  98.  
  99. public void setLink(String link) {
  100. this.link = link;
  101. }
  102.  
  103. public int getPrice() {
  104. return price;
  105. }
  106.  
  107. public void setPrice(int price) {
  108. this.price = price;
  109. }
  110.  
  111. public int getCosts() {
  112. return costs;
  113. }
  114.  
  115. public void setCosts(int costs) {
  116. this.costs = costs;
  117. }
  118.  
  119. public String getDiscription() {
  120. return discription;
  121. }
  122.  
  123. public void setDiscription(String discription) {
  124. this.discription = discription;
  125. }
  126.  
  127. public Timestamp getDate() {
  128. return date;
  129. }
  130.  
  131. public void setDate(Timestamp date) {
  132. this.date = date;
  133. }
  134.  
  135. public boolean isActually() {
  136. return actually;
  137. }
  138.  
  139. public void setActually(boolean actually) {
  140. this.actually = actually;
  141. }
  142.  
  143. public Set<Agent> getAgents() {
  144. return agents;
  145. }
  146.  
  147. public void setAgents(Set<Agent> agents) {
  148. this.agents = agents;
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement