KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > jpetstore > persistence > sqlmapdao > AccountSqlMapDao


1 /**
2  * User: Clinton Begin
3  * Date: Jul 13, 2003
4  * Time: 7:20:13 PM
5  */

6 package com.ibatis.jpetstore.persistence.sqlmapdao;
7
8 import com.ibatis.dao.client.DaoManager;
9 import com.ibatis.jpetstore.domain.Account;
10 import com.ibatis.jpetstore.persistence.iface.AccountDao;
11
12 import java.util.List JavaDoc;
13
14 public class AccountSqlMapDao extends BaseSqlMapDao implements AccountDao {
15
16   public AccountSqlMapDao(DaoManager daoManager) {
17     super(daoManager);
18   }
19
20   public Account getAccount(String JavaDoc username) {
21     return (Account) queryForObject("getAccountByUsername", username);
22   }
23
24   public List JavaDoc getUsernameList() {
25     return queryForList("getUsernameList", null);
26   }
27
28   public Account getAccount(String JavaDoc username, String JavaDoc password) {
29     Account account = new Account();
30     account.setUsername(username);
31     account.setPassword(password);
32     return (Account) queryForObject("getAccountByUsernameAndPassword", account);
33   }
34
35   public void insertAccount(Account account) {
36     update("insertAccount", account);
37     update("insertProfile", account);
38     update("insertSignon", account);
39   }
40
41   public void updateAccount(Account account) {
42     update("updateAccount", account);
43     update("updateProfile", account);
44
45     if (account.getPassword() != null && account.getPassword().length() > 0) {
46       update("updateSignon", account);
47     }
48   }
49
50
51 }
52
Popular Tags