Java - StackOverflow Exception en Spring

 
Vista:

StackOverflow Exception en Spring

Publicado por Sebastian (1 intervención) el 24/04/2017 14:23:23
Buenas. Tengo un error en mi proyecto del tipo StackOverflow y no puedo entender la razon.
El proyecto es un sistema de gestion de un taller mecanico basado en base de datos en MySQL.

Este seria el mapa de las tablas:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
create table Propietario(
	id bigint(10) auto_increment primary key,
	nombreApellido varchar(100) not null,
	direccion varchar(100) not null,
	telefono varchar(15) not null
);
 
create table Empleado(
	id bigint(10) auto_increment primary key,
	nombre varchar(100) not null,
	apellido varchar(100) not null
);
 
create table OrdenTrabajo(
	id bigint(10) auto_increment primary key,
	patente varchar(10) not null,
	fechaIngreso date not null,
	marca varchar(100) not null,
	modelo varchar(100) not null,
	detalle varchar(200) not null,
	horasEmpleado varchar(10),
	activo boolean default 1,
	importe float,
	idPropietario bigint(10) not null,
	idEmpleado bigint(10) not null,
	foreign key(idPropietario) references Propietario(id),
	foreign key(idEmpleado) references Empleado(id)
);
 
create table Repuesto(
	id bigint(10) auto_increment primary key,
	nombre varchar(100) not null,
	precioUnidad float not null
);
 
create table DetallesRepuesto(
	idOrden bigint(10) not null,
	idRepuesto bigint(10) not null,
	cantidad int not null,
	foreign key(idOrden) references OrdenTrabajo(id),
	foreign key(idRepuesto) references Repuesto(id)
);

Ahora, cuando le quiero agregar Detalles de Repuesto a una orden, me tira el error.
Este seria el DAO de la tabla detallesRepuesto:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
public class DetallesRepuestoDAO {
 
	@Autowired
	SessionFactory sessionFactory;
 
	@Transactional
	public DetallesRepuesto getDetallesRepuesto(Long id)
	{
		Session s = sessionFactory.openSession();
		s.beginTransaction();
		DetallesRepuesto detalle = s.get(DetallesRepuesto.class, id);
		s.close();
		return detalle;
	}
 
	public List<DetallesRepuesto> listar(Long id)
	{
		Session s = sessionFactory.openSession();
		Criteria crit=s.createCriteria(DetallesRepuesto.class);
		crit.add(Restrictions.eq("ordenTrabajo.id", id));
		List<DetallesRepuesto> lista = crit.list();
		s.close();
		return lista;
	}
 
	public void insertarDetallesRepuesto(DetallesRepuesto detallesRepuesto)
	{
		Session s = sessionFactory.openSession();
		s.beginTransaction();
		s.save(detallesRepuesto);
		s.getTransaction().commit();
		s.close();
	}
 
}

Y este el controlador:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
@Controller
@RequestMapping("DetallesRepuesto/")
public class DetallesRepuestoController {
 
	@Autowired
	OrdenTrabajoDAO ordenTrabajoDAO;
 
	@Autowired
	DetallesRepuestoDAO detallesRepuestoDAO;
 
	@Autowired
	RepuestoDAO repuestoDAO;
 
	@RequestMapping("ListaRepuestos/{id}")
	public ModelAndView listarDetallesRepuesto(@PathVariable Long id)
	{
		ModelAndView m = new ModelAndView("DetallesRepuesto/listaRepuestos");
 
		List<DetallesRepuesto> lista = detallesRepuestoDAO.listar(id);
		m.addObject("listaDetalles", lista);
		return m;
 
	}
 
	@RequestMapping(path="Nuevo/{id}")
	public ModelAndView insertarRepuesto(@PathVariable Long id){
		ModelAndView m = new ModelAndView("DetallesRepuesto/insertar");
		m.addObject("det", new DetallesRepuesto());
		m.addObject("repuestos", repuestoDAO.listar());
		m.addObject("id", id);
		return m;
	}
 
	@RequestMapping(path="Nuevo/{id}", method=RequestMethod.POST)
	public String insertarRepuesto(@ModelAttribute("det") DetallesRepuesto det, @PathVariable Long id )
	{
		det.setOrdenTrabajo(ordenTrabajoDAO.getOrdenTrabajo(id));
		det.setRepuesto(repuestoDAO.getRepuesto(det.getRepuesto().getId()));
		detallesRepuestoDAO.insertarDetallesRepuesto(det);
		return "redirect:/DetallesRepuesto/ListaRepuestos/{id}";
	}
 
 
}

Me tira el error al momento de cargar el detalle y volver a al lista segun estos jsp:

Lista
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lista Repuestos</title>
</head>
<body>
	<table border=1>
		<tr>
			<th>Nombre</th>
			<th>Cantidad</th>
		</tr>
		<c:forEach var="repuesto" items="${listaDetalles}">
			<tr>
				<td><c:out value="${repuesto.repuesto.getNombre()}"></c:out></td>
				<td><c:out value="${repuesto.cantidad}"></c:out></td>
			</tr>
		</c:forEach>
	</table>
	<br><br><br><br>
 
	<a href="../Nuevo/${id}">Añadir repuesto</a>
	<br>
	<a href="../../TrabajoFinal/">Volver</a>
</body>
</html>/code]
 
Insertar repuesto
[code]<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insertar Repuesto</title>
</head>
<body>
	<center>
		<form:form modelAttribute="det" action="../Nuevo/${id}" method="POST">
 
			<form:label path="repuesto">Repuesto</form:label> <br>
			<form:select path="repuesto.id">
				<br>
				<c:forEach items="${repuestos}" var="repuesto">
					<form:option value="${repuesto.id}">
						<c:out value="${repuesto.nombre}"></c:out>
					</form:option>
				</c:forEach>
			</form:select>
			<br>
			<form:label path="cantidad">Cantidad</form:label>
			<form:input path="cantidad" />
			<br>
			<br>
			<br>
			<input type="submit" value="Enviar">
			<a href="../../TrabajoFinal/">Volver</a>
 
		</form:form>
	</center>
 
</body>
</html>

Si se necesita alguna otra porcion de codigo, porfa avisar.
Espero que alguien entienda suficiente como para darme una mano.
Muchas gracias!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder