mantis #6716
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@49063 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
d84e1547f9
commit
c0d955dbb0
|
@ -3,6 +3,8 @@ package com.rjconsultores.ventaboletos.dao.hibernate;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.criterion.Order;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
@ -11,6 +13,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.rjconsultores.ventaboletos.dao.ExcepcionPeajeDAO;
|
||||
import com.rjconsultores.ventaboletos.entidad.AbastoCentral;
|
||||
import com.rjconsultores.ventaboletos.entidad.ExcepcionPeaje;
|
||||
|
||||
@Repository("excepcionPeajeDAO")
|
||||
|
@ -32,4 +35,19 @@ implements ExcepcionPeajeDAO {
|
|||
|
||||
return c.list();
|
||||
}
|
||||
|
||||
public List<ExcepcionPeaje> obtenerTodos() {
|
||||
Session session = getSession();
|
||||
session.enableFilter("ativo");
|
||||
Criteria c = getSession().createCriteria(getPersistentClass());
|
||||
c.add(Restrictions.eq("activo", Boolean.TRUE));
|
||||
|
||||
List<ExcepcionPeaje> list = (List<ExcepcionPeaje>)c.list();
|
||||
for (ExcepcionPeaje excepcionPeaje : list) {
|
||||
if(!Hibernate.isInitialized(excepcionPeaje.getLsExcepcionPeajeVigencia())){
|
||||
Hibernate.initialize(excepcionPeaje.getLsExcepcionPeajeVigencia());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,14 @@ import javax.persistence.Table;
|
|||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
|
||||
@Entity
|
||||
@FilterDef(name="ativo")
|
||||
@SequenceGenerator(name = "EXCEPCION_PEAJE_SEQ", sequenceName = "EXCEPCION_PEAJE_SEQ", allocationSize = 1)
|
||||
@Table(name = "EXCEPCION_PEAJE")
|
||||
public class ExcepcionPeaje implements Serializable {
|
||||
public class ExcepcionPeaje implements Serializable,Comparable<ExcepcionPeaje> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -49,7 +53,8 @@ public class ExcepcionPeaje implements Serializable {
|
|||
@OneToOne
|
||||
@JoinColumn(name = "DESTINO_ID")
|
||||
private Parada destino;
|
||||
@OneToMany(mappedBy = "excepcionPeaje", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@OneToMany(mappedBy = "excepcionPeaje", cascade = CascadeType.ALL)//, fetch = FetchType.EAGER
|
||||
@Filter(name="ativo", condition="ACTIVO = 1")
|
||||
private List<ExcepcionPeajeVigencia> lsExcepcionPeajeVigencia;
|
||||
|
||||
public Integer getExcepcionPeajeId() {
|
||||
|
@ -105,4 +110,8 @@ public class ExcepcionPeaje implements Serializable {
|
|||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.ExcepcionPeaje[excepcionPeajeId=" + excepcionPeajeId + "]";
|
||||
}
|
||||
@Override
|
||||
public int compareTo(ExcepcionPeaje excepcionPeaje) {
|
||||
return this.getExcepcionPeajeId().intValue() - excepcionPeaje.getExcepcionPeajeId().intValue();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import javax.persistence.TemporalType;
|
|||
@Entity
|
||||
@SequenceGenerator(name = "EXCEPCION_PEAJE_VIGENCIA_SEQ", sequenceName = "EXCEPCION_PEAJE_VIGENCIA_SEQ", allocationSize = 1)
|
||||
@Table(name = "EXCEPCION_PEAJE_VIGENCIA")
|
||||
public class ExcepcionPeajeVigencia implements Serializable {
|
||||
public class ExcepcionPeajeVigencia implements Serializable ,Comparable<ExcepcionPeajeVigencia> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -238,9 +238,17 @@ private static final long serialVersionUID = 1L;
|
|||
this.precio = precio;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "com.rjconsultores.ventaboletos.entidad.ExcepcionPeajeVigencia[excepcionPeajeVigenciaId=" + excepcionPeajeVigenciaId + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ExcepcionPeajeVigencia excepcionPeajeVigencia) {
|
||||
if(excepcionPeajeVigencia.getExcepcionPeajeVigenciaId() != null){
|
||||
return this.getExcepcionPeajeVigenciaId().intValue() - excepcionPeajeVigencia.getExcepcionPeajeVigenciaId().intValue();
|
||||
}else{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue