Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cl.gl.sgv.database.model;
- import lombok.Data;
- import lombok.NoArgsConstructor;
- import javax.persistence.*;
- import java.util.Date;
- @NoArgsConstructor
- @Entity(name = "tareas")
- public class Tarea {
- @Id
- @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TAR_SEQ")
- @SequenceGenerator(name = "TAR_SEQ", sequenceName = "SEQ_TAREAS", allocationSize = 1)
- private Integer id;
- @Column
- private String seguimiento;
- @Column(name = "fecha_inicio")
- private Date fechaInicio;
- @Column(name = "fecha_termino")
- private Date fechaTermino;
- public Tarea(Integer id, Date fechaInicio, Date fechaTermino, String comentarioSeguimiento, Integer terminada, TipoTarea tipoTarea, Cliente cliente, Usuario usuario) {
- this.id = id;
- this.fechaInicio = fechaInicio;
- this.fechaTermino = fechaTermino;
- this.comentarioSeguimiento = comentarioSeguimiento;
- this.terminada = terminada;
- this.usuario = usuario;
- this.cliente = cliente;
- this.tipoTarea = tipoTarea;
- }
- @Column(name = "comentario_seguimiento")
- private String comentarioSeguimiento;
- @Column
- private Integer terminada;
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "usuario_id")
- private Usuario usuario;
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "cliente_id")
- private Cliente cliente;
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "tipo_tarea_id")
- private TipoTarea tipoTarea;
- public Integer getId() {
- return id;
- }
- public void setId(Integer id) {
- this.id = id;
- }
- public String getSeguimiento() {
- return seguimiento;
- }
- public void setSeguimiento(String seguimiento) {
- this.seguimiento = seguimiento;
- }
- public Date getFechaInicio() {
- return fechaInicio;
- }
- public void setFechaInicio(Date fechaInicio) {
- this.fechaInicio = fechaInicio;
- }
- public Date getFechaTermino() {
- return fechaTermino;
- }
- public void setFechaTermino(Date fechaTermino) {
- this.fechaTermino = fechaTermino;
- }
- public String getComentarioSeguimiento() {
- return comentarioSeguimiento;
- }
- public void setComentarioSeguimiento(String comentarioSeguimiento) {
- this.comentarioSeguimiento = comentarioSeguimiento;
- }
- public Integer getTerminada() {
- return terminada;
- }
- public void setTerminada(Integer terminada) {
- this.terminada = terminada;
- }
- public Usuario getUsuario() {
- return usuario;
- }
- public void setUsuario(Usuario usuario) {
- this.usuario = usuario;
- }
- public Cliente getCliente() {
- return cliente;
- }
- public void setCliente(Cliente cliente) {
- this.cliente = cliente;
- }
- public TipoTarea getTipoTarea() {
- return tipoTarea;
- }
- public void setTipoTarea(TipoTarea tipoTarea) {
- this.tipoTarea = tipoTarea;
- }
- }
- ---------------------- query -------
- 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) " +
- "FROM tareas tar " +
- "WHERE tar.usuario = :usuario ORDER BY tar.id DESC", Tarea.class)
- .setParameter("usuario", this)
- .getResultList();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement