programa parace corriendo aun despues de haber terminado
Publicado por Marco Mendinueta (19 intervenciones) el 08/04/2015 00:17:43
Estoy testeando un programa y despues de haber terminado me sigue saliendo en la ventana de OUTPUT como si el programa estuviera corriendo
Alguien me puede decir a que se debe?
este es el codigo de testeo
import com.mps.dao.HibernateUtil;
import com.mps.dao.InterfaceMenu;
import com.mps.modelo.Menu;
import com.mps.modelo.Programa;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import com.mps.dao.MenuDao;
import com.mps.modelo.Aplicacion;
import com.mps.modelo.PerfilPrograma;
import java.awt.List;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import org.hibernate.Query;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author MMENDINUETA
*/
public class Test {
public static void main(String args[]) {
// /*
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
ArrayList<Aplicacion> lstAplicacion = new ArrayList();
ArrayList<PerfilPrograma> lstPerfilPrograma = new ArrayList();
ArrayList<Menu> lstMenu = new ArrayList();
ArrayList<Programa> lstPrograma = new ArrayList();
//Programa prg = new Programa();
Integer codigoAplicacion = 1;
Integer codigoPerfil = 1;
String cmdSql = new String();
try {
//ArrayList<Programa> prg_new =new ArrayList();
/*
cmdSql = "Select f FROM PerfilPrograma f LEFT JOIN FETCH f.programa prg "
+ "LEFT JOIN FETCH f.programa.menu mnu "
+ "LEFT JOIN FETCH f.programa.aplicacion apl "
+ "LEFT JOIN FETCH f.perfil prf "
+ "Where prf.perfilId=:codigoPerfil and apl.aplicacionId=:codigoAplicacion ";
*/
cmdSql = "Select prfprg "
+ "FROM PerfilPrograma prfprg "
+ "LEFT JOIN prfprg.programa prg "
+ "LEFT JOIN prfprg.programa.menu mnu "
+ "LEFT JOIN prfprg.programa.aplicacion apl "
+ "LEFT JOIN prfprg.perfil prf "
+ "Where apl.aplicacionId=:codigoAplicacion and prf.perfilId=:codigoPerfil "
+ "Order By apl.aplicacionOrden,mnu.menuOrden,prfprg.perfilProgramaOrden ";
//listaMenu.addAll(session.createQuery(cmdSql).list());
Query jQuery = session.createQuery(cmdSql);
jQuery.setParameter("codigoAplicacion", codigoAplicacion);
jQuery.setParameter("codigoPerfil", codigoPerfil);
lstPerfilPrograma.addAll(jQuery.list());
//session.close();
/*
Set<Menu> mnu = new LinkedHashSet<Menu>(lista);
lista.clear();
lista.addAll(mnu);
*/
// /*
/*Llenamos la lista de programas */
for (PerfilPrograma prf : lstPerfilPrograma) {
lstPrograma.add(prf.getPrograma()); //Llenamos los programas de la opcion del menu
lstMenu.add(prf.getPrograma().getMenu()); //Llenamos el menu
lstAplicacion.add(prf.getPrograma().getAplicacion()); //Llenamos la aplicacion
}
/*Borramos las aplicaciones que estan repetidas */
Set<Aplicacion> apl_new = new LinkedHashSet<Aplicacion>(lstAplicacion);
lstAplicacion.clear();
lstAplicacion.addAll(apl_new);
/*Borramos las opciones del menu que estan repetidas */
Set<Menu> mnu_new = new LinkedHashSet<Menu>(lstMenu);
lstMenu.clear();
lstMenu.addAll(mnu_new);
//
for (Menu mnu : lstMenu) {
JOptionPane.showMessageDialog(null, "id :" + mnu.getMenuId() + " programaNombre: " + mnu.getMenuNombre());
//JOptionPane.showMessageDialog(null," Menu id :" + prg.getMenu().getMenuId()+"Nombre: "+prg.getMenu().getMenuNombre());
//JOptionPane.showMessageDialog(null,"Programa id :" + prg.getProgramaId()+"Nombre: "+prg.getProgramaNombre());
}
if (!tx.wasCommitted()) {
tx.commit();
}
session.close();
} catch (Exception ex) {
// if (tx!=null)
// {
// tx.rollback();
// }
//throw new RuntimeException("No se pudo actualizar la clase");
throw new RuntimeException(ex.getMessage());
} finally {
HibernateUtil.closeSessionFactory();
// session.close();
}
// */
/*
ArrayList<Menu> lista = new ArrayList();
InterfaceMenu dao = new MenuDao();
lista.addAll(dao.lista());
for (Menu mnu : lista) {
JOptionPane.showMessageDialog(null,"Id :"+ mnu.getMenuId()+" Nombre :"+mnu.getMenuNombre());
}
// */
}
}
Alguien me puede decir a que se debe?
este es el codigo de testeo
import com.mps.dao.HibernateUtil;
import com.mps.dao.InterfaceMenu;
import com.mps.modelo.Menu;
import com.mps.modelo.Programa;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import com.mps.dao.MenuDao;
import com.mps.modelo.Aplicacion;
import com.mps.modelo.PerfilPrograma;
import java.awt.List;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import org.hibernate.Query;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author MMENDINUETA
*/
public class Test {
public static void main(String args[]) {
// /*
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
ArrayList<Aplicacion> lstAplicacion = new ArrayList();
ArrayList<PerfilPrograma> lstPerfilPrograma = new ArrayList();
ArrayList<Menu> lstMenu = new ArrayList();
ArrayList<Programa> lstPrograma = new ArrayList();
//Programa prg = new Programa();
Integer codigoAplicacion = 1;
Integer codigoPerfil = 1;
String cmdSql = new String();
try {
//ArrayList<Programa> prg_new =new ArrayList();
/*
cmdSql = "Select f FROM PerfilPrograma f LEFT JOIN FETCH f.programa prg "
+ "LEFT JOIN FETCH f.programa.menu mnu "
+ "LEFT JOIN FETCH f.programa.aplicacion apl "
+ "LEFT JOIN FETCH f.perfil prf "
+ "Where prf.perfilId=:codigoPerfil and apl.aplicacionId=:codigoAplicacion ";
*/
cmdSql = "Select prfprg "
+ "FROM PerfilPrograma prfprg "
+ "LEFT JOIN prfprg.programa prg "
+ "LEFT JOIN prfprg.programa.menu mnu "
+ "LEFT JOIN prfprg.programa.aplicacion apl "
+ "LEFT JOIN prfprg.perfil prf "
+ "Where apl.aplicacionId=:codigoAplicacion and prf.perfilId=:codigoPerfil "
+ "Order By apl.aplicacionOrden,mnu.menuOrden,prfprg.perfilProgramaOrden ";
//listaMenu.addAll(session.createQuery(cmdSql).list());
Query jQuery = session.createQuery(cmdSql);
jQuery.setParameter("codigoAplicacion", codigoAplicacion);
jQuery.setParameter("codigoPerfil", codigoPerfil);
lstPerfilPrograma.addAll(jQuery.list());
//session.close();
/*
Set<Menu> mnu = new LinkedHashSet<Menu>(lista);
lista.clear();
lista.addAll(mnu);
*/
// /*
/*Llenamos la lista de programas */
for (PerfilPrograma prf : lstPerfilPrograma) {
lstPrograma.add(prf.getPrograma()); //Llenamos los programas de la opcion del menu
lstMenu.add(prf.getPrograma().getMenu()); //Llenamos el menu
lstAplicacion.add(prf.getPrograma().getAplicacion()); //Llenamos la aplicacion
}
/*Borramos las aplicaciones que estan repetidas */
Set<Aplicacion> apl_new = new LinkedHashSet<Aplicacion>(lstAplicacion);
lstAplicacion.clear();
lstAplicacion.addAll(apl_new);
/*Borramos las opciones del menu que estan repetidas */
Set<Menu> mnu_new = new LinkedHashSet<Menu>(lstMenu);
lstMenu.clear();
lstMenu.addAll(mnu_new);
//
for (Menu mnu : lstMenu) {
JOptionPane.showMessageDialog(null, "id :" + mnu.getMenuId() + " programaNombre: " + mnu.getMenuNombre());
//JOptionPane.showMessageDialog(null," Menu id :" + prg.getMenu().getMenuId()+"Nombre: "+prg.getMenu().getMenuNombre());
//JOptionPane.showMessageDialog(null,"Programa id :" + prg.getProgramaId()+"Nombre: "+prg.getProgramaNombre());
}
if (!tx.wasCommitted()) {
tx.commit();
}
session.close();
} catch (Exception ex) {
// if (tx!=null)
// {
// tx.rollback();
// }
//throw new RuntimeException("No se pudo actualizar la clase");
throw new RuntimeException(ex.getMessage());
} finally {
HibernateUtil.closeSessionFactory();
// session.close();
}
// */
/*
ArrayList<Menu> lista = new ArrayList();
InterfaceMenu dao = new MenuDao();
lista.addAll(dao.lista());
for (Menu mnu : lista) {
JOptionPane.showMessageDialog(null,"Id :"+ mnu.getMenuId()+" Nombre :"+mnu.getMenuNombre());
}
// */
}
}
Valora esta pregunta


0