1 package ch.ige.edossier.web.server.dao;
2
3 import java.sql.*;
4 import java.util.ArrayList;
5 import java.util.List;
6 import org.apache.log4j.Logger;
7 import ch.ige.edossier.util.DBHelper;
8 import ch.ige.edossier.web.vo.TMKindVO;
9
10
18 public class TMKindDAO
19 {
20 private static final Logger LOG = Logger.getLogger( TMKindDAO.class );
22
23
30 public List select( int dossierId, int languageCd ) throws SQLException
31 {
32 Connection con = null;
33 PreparedStatement ps = null;
34 ResultSet rs = null;
35 String query = null;
36 List list = new ArrayList();
37 TMKindVO tmKindVO = null;
38
39 try
40 {
41 query = "SELECT a.tmkind_id, a.language_cd, a.description, a.created_dat, a.changed_dat, " +
42 "b.tmkind_id, b.dossier_id, b.language_cd " +
43 "FROM edossier.tmkind a, edossier.tmkind_dossier b " +
44 "WHERE b.dossier_id = ? AND a.language_cd = ? " +
45 "AND a.tmkind_id = b.tmkind_id " +
46 "ORDER BY description";
47
48 con = DBHelper.getInstance().getEsolutionConnection();
49 ps = con.prepareStatement( query );
50 ps.setInt( 1, dossierId );
51 ps.setInt( 2, languageCd );
52 rs = ps.executeQuery();
53
54 list.clear();
55
56 while( rs.next() )
57 {
58 tmKindVO = new TMKindVO();
59 tmKindVO.setTmkindId( rs.getInt( "tmkind_id" ) );
60 tmKindVO.setLanguageCd( rs.getInt( "language_cd" ) );
61 tmKindVO.setDossierId( rs.getInt( "dossier_id" ) );
62 tmKindVO.setDescription( rs.getString( "description" ) );
63 tmKindVO.setCreatedDat( rs.getDate( "created_dat" ) );
64 tmKindVO.setChangedDat( rs.getDate( "changed_dat" ) );
65
66 list.add( tmKindVO );
67 }
68 }
69 catch( SQLException sqlex )
70 {
71 LOG.debug( query + "\n" +
72 " dossierId = <" + dossierId + "> \n" +
73 " languageCd = <" + languageCd + "> \n" );
74 throw sqlex;
75 }
76 finally
77 {
78 DBHelper.getInstance().close( con, ps );
79 }
80 return list;
81 }
82 }
83