1    package com.instantbank.collections.ach;
2    
3    
4    import java.sql.PreparedStatement;
5    import java.sql.ResultSet;
6    import java.sql.SQLException;
7    import java.util.List;
8    import javax.naming.NamingException;
9    import java.io.Serializable;
10   
11   public class AchXacDO
12       implements DataObject, Serializable {
13   
14     private static final String SEQUENCE_NAME = "ACH_XAC_SEQ";
15   
16     private AchXac achXac = null;
17     private long id = -1;
18     private long csId = -1;  // Clearing House primary key
19     private long lastChangedBy = -1;
20     private String lastChangedDate = null;
21   
22   
23     public AchXacDO() {
24       super();
25     }
26   
27   
28     public AchXacDO(long primaryKey) {
29       setId(primaryKey);
30     }
31   
32   
33     public AchXacDO(AchXac theAchXac, long theId, long theCsId, long theLastChangedBy,
34                     String theLastChangedDate) {
35   
36       setAchXac(theAchXac);
37       setId(theId);
38       setCsId(theCsId);
39       setLastChangedBy(theLastChangedBy);
40       setLastChangedDate(theLastChangedDate);
41     }
42   
43   
44     public AchXac getAchXac() {
45       return achXac;
46     }
47   
48   
49     public long getId() {
50       return id;
51     }
52   
53   
54     public long getCsId() {
55       return csId;
56     }
57   
58   
59     public long getLastChangedBy() {
60       return lastChangedBy;
61     }
62   
63   
64     public String getLastChangedDate() {
65       return lastChangedDate;
66     }
67   
68   
69     public String getFindByPrimaryKeySQL() {
70       return FIND_BY_PK;
71     }
72   
73   
74     public String getSequenceObjectName() {
75       return SEQUENCE_NAME;
76     }
77   
78   
79     public String getCreateSQL() {
80       return CREATE_SQL;
81     }
82   
83   
84     public String getUpdateSQL() {
85       return UPDATE_SQL;
86     }
87   
88   
89     public String getRemoveSQL() {
90       return REMOVE_SQL;
91     }
92   
93   
94     public void setAchXac(AchXac arg) {
95       achXac = arg;
96     }
97   
98   
99     public void setId(long l) {
100      id = l;
101    }
102  
103  
104    public void setCsId(long l) {
105      csId = l;
106    }
107  
108  
109    public void setLastChangedBy(long l) {
110      lastChangedBy = l;
111    }
112  
113  
114    public void setLastChangedDate(String s) {
115      lastChangedDate = s;
116    }
117  
118  
119    /**
120     * Returns a list of LongWrapper objects of keys for this DataObject
121     *
122     * @param companySystemId Description of the Parameter
123     * @return The primaryKeys value
124     * @throws SQLException Description of the Exception
125     * @throws NamingException Description of the Exception
126     */
127    public static List getPrimaryKeys(long companySystemId) throws SQLException, NamingException {
128      return AchDAO.getPrimaryKeys(
129        "select XAC_ID from ACH_XAC where XAC_CS_ID="
130        + companySystemId);
131    }
132  
133    // Sql to populate all fields of this object
134    private static final String FIND_BY_PK =
135      "SELECT XAC_CS_ID, XAC_TRAN_CODE, XAC_TRAN_DESC, XAC_FEE_INDICATOR, XAC_STATUS, " +
136      "XAC_LAST_CHANGED_BY, to_char(XAC_LAST_CHANGED_DATE,  'mm-dd-yyyy') " +
137      "FROM  ACH_XAC " +
138      "WHERE XAC_ID = ?";
139  
140    // Populate this object that, so far, only has a primary key in it
141    public void populate(ResultSet rs) throws SQLException {
142      if(rs == null) {
143        return;
144      }
145      setAchXac(new AchXac(rs.getString(2), rs.getString(3), rs.getString(4),
146        rs.getString(5)));
147      setCsId(rs.getLong(1));
148      setLastChangedBy(rs.getLong(6));
149      setLastChangedDate(rs.getString(7));
150    }
151  
152  
153    // Sql to store this object
154    private static final String CREATE_SQL =
155      "insert into ACH_XAC " +
156      "(XAC_ID, XAC_CS_ID, XAC_TRAN_CODE, XAC_TRAN_DESC, XAC_FEE_INDICATOR,XAC_STATUS, XAC_LAST_CHANGED_BY, XAC_LAST_CHANGED_DATE) " +
157      "values (?, ?, ?, ?, ?, ?, ?, sysdate)";
158  
159  
160    public void prepareCreateStatement(PreparedStatement ps) throws SQLException {
161      if(ps == null) {
162        return;
163      }
164      ps.setLong(1, this.getId());
165      ps.setLong(2, this.getCsId());
166      ps.setString(3, this.getAchXac().getTranCode());
167      ps.setString(4, this.getAchXac().getTranDesc());
168      ps.setString(5, this.getAchXac().getFeeIndicator());
169      ps.setString(6, this.getAchXac().getStatus());
170      ps.setLong(7, this.getLastChangedBy());
171    }
172  
173  
174    // Sql to update this object
175    private static final String UPDATE_SQL =
176      "update ACH_XAC " +
177      "set    XAC_CS_ID= ?, XAC_TRAN_CODE= ?, XAC_TRAN_DESC= ?, XAC_FEE_INDICATOR= ? , XAC_STATUS= ?, " +
178      "XAC_LAST_CHANGED_BY= ?, XAC_LAST_CHANGED_DATE=sysdate " +
179      "where  XAC_ID= ? ";
180  
181  
182    public void prepareUpdateStatement(PreparedStatement ps) throws SQLException {
183      if(ps == null) {
184        return;
185      }
186      ps.setLong(1, this.getCsId());
187      ps.setString(2, this.getAchXac().getTranCode());
188      ps.setString(3, this.getAchXac().getTranDesc());
189      ps.setString(4, this.getAchXac().getFeeIndicator());
190      ps.setString(5, this.getAchXac().getStatus());
191      ps.setLong(6, this.getLastChangedBy());
192      ps.setLong(7, this.getId());
193  
194    }
195  
196    // Sql to remove this object from the database
197    private static final String REMOVE_SQL =
198      "delete from ACH_XAC " +
199      "whereXAC_ID= ? ";
200  
201  
202    public void prepareRemoveStatement(PreparedStatement ps) throws SQLException {
203      if(ps == null) {
204        return;
205      }
206      ps.setLong(1, this.getId());
207    }
208  
209  
210    public String toString() {
211      return "[" + id + '|' + achXac == null ? "" : achXac.toString() + '|' + csId + "]";
212    }
213  }
214