01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.odal.petstore.persistence.dao;
10:
11: import com.completex.objective.components.persistency.MappingPersistency;
12: import com.completex.objective.components.persistency.OdalPersistencyException;
13: import com.odal.petstore.OdalPetstoreException;
14: import com.odal.petstore.domain.Account;
15: import com.odal.petstore.persistence.gen.cmp.CmpAccount;
16: import com.odal.petstore.persistence.iface.AccountDao;
17:
18: /**
19: * @author Gennady Krizhevsky
20: */
21: public class AccountDaoImpl implements AccountDao {
22: private MappingPersistency persistency;
23:
24: public AccountDaoImpl(MappingPersistency persistency) {
25: this .persistency = persistency;
26: }
27:
28: public Account getAccount(String username)
29: throws OdalPetstoreException {
30: try {
31: CmpAccount account = new CmpAccount();
32: account.setUserId(username);
33: return (Account) persistency.selectFirst(account);
34: } catch (OdalPersistencyException e) {
35: throw new OdalPetstoreException(e);
36: }
37: }
38:
39: public Account getAccount(String username, String password)
40: throws OdalPetstoreException {
41: try {
42: CmpAccount account = new CmpAccount();
43: account.setUserId(username);
44: account.setPassword(password);
45: return (Account) persistency.selectFirst(account);
46: } catch (OdalPersistencyException e) {
47: throw new OdalPetstoreException(e);
48: }
49: }
50:
51: public void insertAccount(Account account)
52: throws OdalPetstoreException {
53: try {
54: persistency.insert(account);
55: } catch (OdalPersistencyException e) {
56: throw new OdalPetstoreException(e);
57: }
58: }
59:
60: public void updateAccount(Account account)
61: throws OdalPetstoreException {
62: try {
63: persistency.update(account);
64: } catch (OdalPersistencyException e) {
65: throw new OdalPetstoreException(e);
66: }
67: }
68:
69: }
|