Check-in [c77a94e144]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:persintencia reserva
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c77a94e1446159ea180c96f44ade55acb8d629cc
User & Date: malcon 2015-01-11 11:46:42
Context
2015-01-11
15:48
registro cliente web listo, falta validaciones, check-in: ec3074ddc2 user: malcon tags: trunk
11:46
persintencia reserva check-in: c77a94e144 user: malcon tags: trunk
11:12
registro cliente, sale error check-in: 4b8eccaca6 user: malcon tags: trunk
Changes

Changes to src/model/Reserva.java.

1
2



3
4










5





















































package model;




public class Reserva {











}























































>
>
>
|

>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
69
70
71
package model;

import java.io.Serializable;
import java.util.Date;

public class Reserva implements Serializable{

  private static final long serialVersionUID = 1L;
  private  Integer id;
  private String num_reserva;
  private Date fe_reserva;
  private Date fe_expiracion;
  private Paquete paquete;
  //private Precio_Paquete precio_paquete;
  private Date fe_salida;
  private Integer nro_personas;
  private String estado;
  
public Integer getId() {
	return id;
}
public void setId(Integer id) {
	this.id = id;
}
public String getNum_reserva() {
	return num_reserva;
}
public void setNum_reserva(String num_reserva) {
	this.num_reserva = num_reserva;
}
public Date getFe_reserva() {
	return fe_reserva;
}
public void setFe_reserva(Date fe_reserva) {
	this.fe_reserva = fe_reserva;
}
public Date getFe_expiracion() {
	return fe_expiracion;
}
public void setFe_expiracion(Date fe_expiracion) {
	this.fe_expiracion = fe_expiracion;
}
public Paquete getPaquete() {
	return paquete;
}
public void setPaquete(Paquete paquete) {
	this.paquete = paquete;
}
public Date getFe_salida() {
	return fe_salida;
}
public void setFe_salida(Date fe_salida) {
	this.fe_salida = fe_salida;
}
public Integer getNro_personas() {
	return nro_personas;
}
public void setNro_personas(Integer nro_personas) {
	this.nro_personas = nro_personas;
}
public String getEstado() {
	return estado;
}
public void setEstado(String estado) {
	this.estado = estado;
}
  
  
  
  
}

Added src/negocio/ReservaService.java.





























>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package negocio;

import java.util.List;


import model.Reserva;

public interface ReservaService {

	public Reserva obtener(Integer codigo) throws Exception;
	public void actualizar(Reserva reserva) throws Exception ;
	public void registrar(Reserva reserva) throws Exception;
	public List<Reserva> buscar(Reserva reserva) throws Exception;
}

Added src/negocio/ReservaServiceDAO.java.











































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
package negocio;

import java.util.List;

import org.apache.ibatis.session.SqlSession;


import persistencia.mybatis.mapper.ReservaMapper;
import util.MyBatisUtil;

import model.Reserva;

public class ReservaServiceDAO  implements ReservaService{

	@Override
	public Reserva obtener(Integer codigo) throws Exception {
		
		SqlSession session=MyBatisUtil.getSqlSessionFactory().openSession();
		ReservaMapper ReservaMapper=session.getMapper(ReservaMapper.class);
		Reserva reserva=ReservaMapper.obtener(codigo);
		session.close();
		return reserva;
	}

	
	@Override
	public void registrar(Reserva reserva) throws Exception {
		System.out.println("registrar reserva" + reserva.getId());
		SqlSession  session=MyBatisUtil.getSqlSessionFactory().openSession();
		ReservaMapper reservaMapper = session.getMapper(ReservaMapper.class);
		reservaMapper.insertar(reserva);
		session.commit();
		session.close();
		
	}

	@Override
	public List<Reserva> buscar(Reserva reserva) throws Exception {
		SqlSession session=MyBatisUtil.getSqlSessionFactory().openSession();
		ReservaMapper reservaMapper = session.getMapper(ReservaMapper.class);
		List<Reserva> reservas = reservaMapper.buscar(reserva);
		session.close();
		return reservas;
	}


	@Override
	public void actualizar(Reserva reserva) throws Exception {
		// TODO Auto-generated method stub
		
	}

}

Changes to src/persistencia/mybatis/config/mybatis-config.xml.

10
11
12
13
14
15
16


17
18
19
20
21
22
23
	<settings>
		<setting name="defaultStatementTimeout" value="2"/>
	</settings>
	
	<typeAliases>
		<typeAlias type="model.Cliente" alias="cliente"/>
		<typeAlias type="model.Usuario" alias="usuario"/>


	</typeAliases>
	
    <environments default="clase">
    
        <environment id="clase">
            <transactionManager type="JDBC"/>
            <dataSource type="JNDI">







>
>







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
	<settings>
		<setting name="defaultStatementTimeout" value="2"/>
	</settings>
	
	<typeAliases>
		<typeAlias type="model.Cliente" alias="cliente"/>
		<typeAlias type="model.Usuario" alias="usuario"/>
		<typeAlias type="model.Reserva" alias="reserva"/>
		<typeAlias type="model.Reserva" alias="paquete"/>
	</typeAliases>
	
    <environments default="clase">
    
        <environment id="clase">
            <transactionManager type="JDBC"/>
            <dataSource type="JNDI">

Added src/persistencia/mybatis/mapper/ReservaMapper.java.



























>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
package persistencia.mybatis.mapper;

import java.util.List;

import model.Reserva;

public interface ReservaMapper {

		List<Reserva> buscar(Reserva reserva);
		Reserva obtener(Integer codigo);
		void insertar(Reserva reserva);
		void actualizar(Reserva reserva);
}

Added src/persistencia/mybatis/mapper/ReservaMapper.xml.





























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mapper 
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

 <mapper namespace="persistencia.mybatis.mapper.ReservaMapper">
 
     <resultMap type="reserva" id="rmReservaBusqueda">
        <id column="id" property="codigo"/>
<result column="num_reserva" property="num_reserva"/>
        <result column="fe_reserva" property="fe_reserva"/>
        <result column="fe_salida" property="fe_salida"/>
        <result column="fe_expiracion" property="fe_expiracion"/>
        <result column="nro_personas" property="nro_personas"/>
        <result column="estado" property="estado"/>
        <association property="paquete" javaType="paquete">
            	<result column = "paquete_id" property="codigo"/>
        </association>
     </resultMap>
     
    <select id="buscar" resultMap="rmReservaBusqueda" parameterType="reserva">
    	SELECT num_reserva, fe_reserva, fe_salida, fe_expiracion, paquete_id , nro_personas, estado
    	FROM reserva
    	WHERE num_reserva LIKE #{num_reserva}
    </select>
    
    <resultMap type="reserva" id="rmReservaByPK">
        <id column="id" property="codigo"/>
        <result column="num_reserva" property="num_reserva"/>
        <result column="fe_reserva" property="fe_reserva"/>
        <result column="fe_salida" property="fe_salida"/>
        <result column="fe_expiracion" property="fe_expiracion"/>
        <result column="nro_personas" property="nro_personas"/>
        <result column="estado" property="estado"/>
      
    
        <association property="paquete" javaType="paquete">
            	<result column = "paquete_id" property="codigo"/>
        </association>
    </resultMap>
    
 	<select id="obtener" resultMap="rmReservaByPK" parameterType="integer">
 		SELECT num_reserva, fe_reserva, fe_salida, fe_expiracion, paquete_id , nro_personas, estado
 			FROM reserva
 			WHERE id = #{codigo}
 		
 	</select>
 	
 	<insert id="insertar" parameterType="reserva">
 		INSERT INTO reserva(num_reserva, fe_reserva, fe_salida, fe_expiracion, paquete_id , nro_personas, estado)
 		values (#{num_reserva},#{fe_reserva},#{fe_salida},#{fe_expiracion},#{paquete.codigo},#{nro_personas},#{estado})
 	</insert>
 	
 	<update id="actualizar" parameterType="reserva">
 		UPDATE reserva
 		SET estado=#{estado}
 			WHERE id=#{codigo}
 	</update>
 
 
 </mapper>