i have one issue in my code
@Override
public Turno getTurnoRechazado(Turno t) {
LOGGER.info("start here");
Session session = this.sessionManager.getSession();
Criteria criteria = session.createCriteria(Turno.class);
criteria.add(Restrictions.eq("asunto.id", t.getAsunto().getId()));
criteria.add(Restrictions.eq("unidadDestinatario.id", t.getUnidadDestinatario().getId()));
criteria.add(Restrictions.eq("baja", Boolean.TRUE));
LOGGER.info("stop here"); // stop here unique result is not reached in the execution
return (Turno) criteria.uniqueResult();
}
when this code try to be executed all the code is executed except in the last line
return (Turno) criteria.uniqueResult();
this code is on a DAO and this dao is used into a model this model is tagged with @Transactional
this is the function where this code is used
private boolean checaTurnoRechazado(Turno t, Unidad unidadRaiz) {
LOGGER.info("Entra al turno rechazado");
Turno tr = this.turnoDAO.getTurnoRechazado(t);
LOGGER.info("return getTurnoRechazado"); // this line is not executed
Constants.printObject(tr);
... // another code
return Boolean.FALSE;
}
return Boolean.TRUE;
}
this is my entity:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mx.gob.edomex.dgsei.gestion.data.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Temporal;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NamedNativeQueries;
import org.hibernate.annotations.NamedNativeQuery;
import org.hibernate.annotations.Parameter;
import org.springframework.format.annotation.DateTimeFormat;
/**
*
* @author ivonne
*/
@NamedNativeQueries({
@NamedNativeQuery(
name = "callUpdateTurno",
query = "CALL UPDATE_TURNO(:turno)",
resultClass = Turno.class)
})
@Entity
@Table(name = "TURNO")
public class Turno implements java.io.Serializable {
private int id;
private Asunto asunto;
private Unidad unidadRemitente;
private Unidad unidadDestinatario;
private Unidad unidadDestinatarioPrincipal;
private Integer unidadRaiz;
private Servicio servicio;
private String proyecto;
private Date fechaRegistro;
private Date fechaVencimiento;
private Date fechaEnterado;
private Integer hijosTerminados;
private boolean vencido;
private Long avanceRelativo;
private boolean asignar;
private boolean autorizar;
private EstatusTurno estatusTurno;
private Instruccion instruccion;
private String requerimiento;
private Long avanceReal;
private boolean baja;
private boolean responsable;
private Integer hijosRechazados;
private boolean hermanosTerminados;
private Date fechaCierre;
private Date fechaVencimientoOriginal;
private TurnoSupervisor turnoSupervisor;
private List<Movimiento> movimientos = new ArrayList<>();
private List<Prorroga> prorrogas = new ArrayList<>();
public Turno() {
}
public Turno(int id, Asunto asunto, Unidad unidadRemitente, Unidad unidadDestinatario, Unidad unidadDestinatarioPrincipal, Integer unidadRaiz, Servicio servicio, String proyecto, Date fechaRegistro, Date fechaVencimiento, Date fechaEnterado, Integer hijosTerminados, boolean vencido, Long avanceRelativo, boolean asignar, boolean autorizar, EstatusTurno estatusTurno, boolean responsable) {
this.id = id;
this.asunto = asunto;
this.unidadRemitente = unidadRemitente;
this.unidadDestinatario = unidadDestinatario;
this.unidadDestinatarioPrincipal = unidadDestinatarioPrincipal;
this.unidadRaiz = unidadRaiz;
this.servicio = servicio;
this.proyecto = proyecto;
this.fechaRegistro = fechaRegistro;
this.fechaVencimiento = fechaVencimiento;
this.fechaEnterado = fechaEnterado;
this.hijosTerminados = hijosTerminados;
this.vencido = vencido;
this.avanceRelativo = avanceRelativo;
this.asignar = asignar;
this.autorizar = autorizar;
this.estatusTurno = estatusTurno;
this.responsable = responsable;
}
@Id
@GenericGenerator(name = "generator", strategy = "sequence-identity", parameters = @Parameter(name = "sequence", value = "TURNO_SEQ"))
@GeneratedValue(generator = "generator")
@Column(name = "ID", unique = true, nullable = false, precision = 8, scale = 0)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@ManyToOne(fetch = FetchType.LAZY)
@Fetch(org.hibernate.annotations.FetchMode.SELECT)
@JoinColumn(name = "ASUNTO", nullable = false)
public Asunto getAsunto() {
return asunto;
}
public void setAsunto(Asunto asunto) {
this.asunto = asunto;
}
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "UNIDAD_REMITENTE", nullable = false)
public Unidad getUnidadRemitente() {
return unidadRemitente;
}
public void setUnidadRemitente(Unidad unidadRemitente) {
this.unidadRemitente = unidadRemitente;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "UNIDAD_DESTINATARIO", nullable = false)
public Unidad getUnidadDestinatario() {
return unidadDestinatario;
}
public void setUnidadDestinatario(Unidad unidadDestinatario) {
this.unidadDestinatario = unidadDestinatario;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "DESTINATARIO_PRINCIPAL", nullable = true)
public Unidad getUnidadDestinatarioPrincipal() {
return unidadDestinatarioPrincipal;
}
public void setUnidadDestinatarioPrincipal(Unidad unidadDestinatarioPrincipal) {
this.unidadDestinatarioPrincipal = unidadDestinatarioPrincipal;
}
@Column(name = "UNIDAD_RAIZ", precision = 22, scale = 0)
public Integer getUnidadRaiz() {
return unidadRaiz;
}
public void setUnidadRaiz(Integer unidadRaiz) {
this.unidadRaiz = unidadRaiz;
}
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "SERVICIO")
public Servicio getServicio() {
return servicio;
}
public void setServicio(Servicio servicio) {
this.servicio = servicio;
}
public String getProyecto() {
return proyecto;
}
public void setProyecto(String proyecto) {
this.proyecto = proyecto;
}
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Column(name = "FECHA_REGISTRO", nullable = false)
@Temporal(javax.persistence.TemporalType.DATE)
public Date getFechaRegistro() {
return fechaRegistro;
}
public void setFechaRegistro(Date fechaRegistro) {
this.fechaRegistro = fechaRegistro;
}
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Column(name = "FECHA_VENCIMIENTO", nullable = false)
@Temporal(javax.persistence.TemporalType.DATE)
public Date getFechaVencimiento() {
return fechaVencimiento;
}
public void setFechaVencimiento(Date fechaVencimiento) {
this.fechaVencimiento = fechaVencimiento;
}
@Column(name = "HIJOS_TERMINADOS")
public Integer getHijosTerminados() {
return hijosTerminados;
}
public void setHijosTerminados(Integer hijosTerminados) {
this.hijosTerminados = hijosTerminados;
}
@Column(name = "VENCIDO")
public boolean isVencido() {
return vencido;
}
public void setVencido(boolean vencido) {
this.vencido = vencido;
}
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Column(name = "FECHA_ENTERADO", nullable = false)
@Temporal(javax.persistence.TemporalType.DATE)
public Date getFechaEnterado() {
return fechaEnterado;
}
public void setFechaEnterado(Date fechaEnterado) {
this.fechaEnterado = fechaEnterado;
}
@Column(name = "AVANCE_RELATIVO", precision = 8, scale = 0)
public Long getAvanceRelativo() {
return avanceRelativo;
}
public void setAvanceRelativo(Long avanceRelativo) {
this.avanceRelativo = avanceRelativo;
}
@Column(name = "ASIGNAR")
public boolean isAsignar() {
return asignar;
}
public void setAsignar(boolean asignar) {
this.asignar = asignar;
}
@Column(name = "AUTORIZAR")
public boolean isAutorizar() {
return autorizar;
}
public void setAutorizar(boolean autorizar) {
this.autorizar = autorizar;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ESTATUS_TURNO", nullable = false)
public EstatusTurno getEstatusTurno() {
return estatusTurno;
}
public void setEstatusTurno(EstatusTurno estatusTurno) {
this.estatusTurno = estatusTurno;
}
@JsonIgnore
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "INSTRUCCION")
public Instruccion getInstruccion() {
return instruccion;
}
public void setInstruccion(Instruccion instruccion) {
this.instruccion = instruccion;
}
@Column(name = "REQUERIMIENTO", nullable = true, length = 250)
public String getRequerimiento() {
return requerimiento;
}
public void setRequerimiento(String requerimiento) {
this.requerimiento = requerimiento;
}
@Column(name = "AVANCE_REAL", precision = 8, scale = 0)
public Long getAvanceReal() {
return avanceReal;
}
public void setAvanceReal(Long avanceReal) {
this.avanceReal = avanceReal;
}
@Column(name = "BAJA")
public boolean isBaja() {
return baja;
}
public void setBaja(boolean baja) {
this.baja = baja;
}
@Column(name = "HIJOS_RECHAZADOS")
public Integer getHijosRechazados() {
return hijosRechazados;
}
public void setHijosRechazados(Integer hijosRechazados) {
this.hijosRechazados = hijosRechazados;
}
@JsonIgnore
@Fetch(org.hibernate.annotations.FetchMode.SELECT)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "turno", cascade = {CascadeType.ALL}, orphanRemoval = true)
public List<Movimiento> getMovimientos() {
return this.movimientos;
}
public void setMovimientos(List<Movimiento> movimientos) {
this.movimientos = movimientos;
}
@Column(name = "RESPONSABLE", nullable = true)
public boolean isResponsable() {
return responsable;
}
public void setResponsable(boolean responsable) {
this.responsable = responsable;
}
@Column(name = "HERMANOS_TERMINADOS")
public boolean isHermanosTerminados() {
return hermanosTerminados;
}
public void setHermanosTerminados(boolean hermanosTerminados) {
this.hermanosTerminados = hermanosTerminados;
}
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Column(name = "FECHA_CIERRE", nullable = true)
@Temporal(javax.persistence.TemporalType.DATE)
public Date getFechaCierre() {
return fechaCierre;
}
public void setFechaCierre(Date fechaCierre) {
this.fechaCierre = fechaCierre;
}
@DateTimeFormat(pattern = "dd/MM/yyyy")
@Column(name = "FECHA_VENCIMIENTO_ORIGINAL", nullable = true)
@Temporal(javax.persistence.TemporalType.DATE)
public Date getFechaVencimientoOriginal() {
return fechaVencimientoOriginal;
}
public void setFechaVencimientoOriginal(Date fechaVencimientoOriginal) {
this.fechaVencimientoOriginal = fechaVencimientoOriginal;
}
@OneToOne(fetch = FetchType.LAZY, mappedBy = "turno", cascade = {CascadeType.ALL})
@PrimaryKeyJoinColumn(name="TURNO", referencedColumnName="ID")
public TurnoSupervisor getTurnoSupervisor() {
return turnoSupervisor;
}
public void setTurnoSupervisor(TurnoSupervisor turnoSupervisor) {
this.turnoSupervisor = turnoSupervisor;
}
@JsonIgnore
@Fetch(org.hibernate.annotations.FetchMode.SELECT)
@OneToMany(fetch = FetchType.LAZY, mappedBy = "turno", cascade = {CascadeType.ALL}, orphanRemoval = true)
public List<Prorroga> getProrrogas() {
return prorrogas;
}
public void setProrrogas(List<Prorroga> prorrogas) {
this.prorrogas = prorrogas;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof Turno)) {
return false;
}
final Turno turno = (Turno) other;
return turno.getId() == this.getId();
}
@Override
public int hashCode() {
return new Integer(id).hashCode();
}
}
and this is the output:
14:17:04,120 INFO [stdout] (http--127.0.0.1-8080-6) 2015-10-05 14:17:04 INFO AutorizadorController:244 - entra
14:17:04,199 INFO [stdout] (http--127.0.0.1-8080-6) 2015-10-05 14:17:04 INFO AutorizadorModelImpl:467 - Entra al turno rechazado
14:17:04,199 INFO [mx.gob.edomex.dgsei.gestion.data.dao.impl.TurnoDAOImpl] (http--127.0.0.1-8080-6) start here
14:17:04,199 INFO [mx.gob.edomex.dgsei.gestion.data.dao.impl.TurnoDAOImpl] (http--127.0.0.1-8080-6) stop here
rest of the function is waiting for the execution of this line but never happend.
can somebody help or know how this issue is happend?
thanks in advance.