Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. package cl.gl.sgv.database.model;
  2.  
  3. import lombok.Data;
  4. import lombok.NoArgsConstructor;
  5.  
  6. import javax.persistence.*;
  7. import java.util.Date;
  8.  
  9. @NoArgsConstructor
  10. @Entity(name = "tareas")
  11. public class Tarea {
  12.  
  13. @Id
  14. @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TAR_SEQ")
  15. @SequenceGenerator(name = "TAR_SEQ", sequenceName = "SEQ_TAREAS", allocationSize = 1)
  16. private Integer id;
  17.  
  18. @Column
  19. private String seguimiento;
  20.  
  21. @Column(name = "fecha_inicio")
  22. private Date fechaInicio;
  23.  
  24. @Column(name = "fecha_termino")
  25. private Date fechaTermino;
  26.  
  27. public Tarea(Integer id, Date fechaInicio, Date fechaTermino, String comentarioSeguimiento, Integer terminada, TipoTarea tipoTarea, Cliente cliente, Usuario usuario) {
  28. this.id = id;
  29. this.fechaInicio = fechaInicio;
  30. this.fechaTermino = fechaTermino;
  31. this.comentarioSeguimiento = comentarioSeguimiento;
  32. this.terminada = terminada;
  33. this.usuario = usuario;
  34. this.cliente = cliente;
  35. this.tipoTarea = tipoTarea;
  36. }
  37.  
  38. @Column(name = "comentario_seguimiento")
  39. private String comentarioSeguimiento;
  40.  
  41. @Column
  42. private Integer terminada;
  43.  
  44. @ManyToOne(fetch = FetchType.LAZY)
  45. @JoinColumn(name = "usuario_id")
  46. private Usuario usuario;
  47.  
  48. @ManyToOne(fetch = FetchType.LAZY)
  49. @JoinColumn(name = "cliente_id")
  50. private Cliente cliente;
  51.  
  52. @ManyToOne(fetch = FetchType.LAZY)
  53. @JoinColumn(name = "tipo_tarea_id")
  54. private TipoTarea tipoTarea;
  55.  
  56. public Integer getId() {
  57. return id;
  58. }
  59.  
  60. public void setId(Integer id) {
  61. this.id = id;
  62. }
  63.  
  64. public String getSeguimiento() {
  65. return seguimiento;
  66. }
  67.  
  68. public void setSeguimiento(String seguimiento) {
  69. this.seguimiento = seguimiento;
  70. }
  71.  
  72. public Date getFechaInicio() {
  73. return fechaInicio;
  74. }
  75.  
  76. public void setFechaInicio(Date fechaInicio) {
  77. this.fechaInicio = fechaInicio;
  78. }
  79.  
  80. public Date getFechaTermino() {
  81. return fechaTermino;
  82. }
  83.  
  84. public void setFechaTermino(Date fechaTermino) {
  85. this.fechaTermino = fechaTermino;
  86. }
  87.  
  88. public String getComentarioSeguimiento() {
  89. return comentarioSeguimiento;
  90. }
  91.  
  92. public void setComentarioSeguimiento(String comentarioSeguimiento) {
  93. this.comentarioSeguimiento = comentarioSeguimiento;
  94. }
  95.  
  96. public Integer getTerminada() {
  97. return terminada;
  98. }
  99.  
  100. public void setTerminada(Integer terminada) {
  101. this.terminada = terminada;
  102. }
  103.  
  104. public Usuario getUsuario() {
  105. return usuario;
  106. }
  107.  
  108. public void setUsuario(Usuario usuario) {
  109. this.usuario = usuario;
  110. }
  111.  
  112. public Cliente getCliente() {
  113. return cliente;
  114. }
  115.  
  116. public void setCliente(Cliente cliente) {
  117. this.cliente = cliente;
  118. }
  119.  
  120. public TipoTarea getTipoTarea() {
  121. return tipoTarea;
  122. }
  123.  
  124. public void setTipoTarea(TipoTarea tipoTarea) {
  125. this.tipoTarea = tipoTarea;
  126. }
  127. }
  128.  
  129.  
  130.  
  131.  
  132. ---------------------- query -------
  133.  
  134. return em.createQuery("SELECT new cl.gl.sgv.database.model.Tarea(tar.id, tar.fechaInicio, tar.fechaTermino, tar.comentarioSeguimiento, tar.terminada, tar.tipoTarea, tar.cliente, tar.usuario) " +
  135. "FROM tareas tar " +
  136. "WHERE tar.usuario = :usuario ORDER BY tar.id DESC", Tarea.class)
  137. .setParameter("usuario", this)
  138. .getResultList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement