1
22
23 package com.liferay.mail.service.persistence;
24
25 import com.liferay.mail.NoSuchCyrusUserException;
26 import com.liferay.mail.model.CyrusUser;
27 import com.liferay.portal.SystemException;
28 import com.liferay.portal.kernel.dao.orm.ObjectNotFoundException;
29 import com.liferay.portal.kernel.dao.orm.Session;
30 import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
31
32
38 public class CyrusUserPersistence extends BasePersistenceImpl {
39
40 public void remove(long userId)
41 throws NoSuchCyrusUserException, SystemException {
42
43 Session session = null;
44
45 try {
46 session = openSession();
47
48 CyrusUser user = (CyrusUser)session.load(
49 CyrusUser.class, String.valueOf(userId));
50
51 session.delete(user);
52
53 session.flush();
54 }
55 catch (ObjectNotFoundException onfe) {
56 throw new NoSuchCyrusUserException();
57 }
58 catch (Exception e) {
59 throw processException(e);
60 }
61 finally {
62 closeSession(session);
63 }
64 }
65
66 public void update(CyrusUser user) throws SystemException {
67 Session session = null;
68
69 try {
70 session = openSession();
71
72 try {
73 CyrusUser userModel = (CyrusUser)session.load(
74 CyrusUser.class, String.valueOf(user.getUserId()));
75
76 userModel.setPassword(user.getPassword());
77
78 session.flush();
79 }
80 catch (ObjectNotFoundException onfe) {
81 CyrusUser userModel = new CyrusUser(
82 user.getUserId(), user.getPassword());
83
84 session.save(userModel);
85
86 session.flush();
87 }
88 }
89 catch (Exception e) {
90 throw processException(e);
91 }
92 finally {
93 closeSession(session);
94 }
95 }
96
97 public CyrusUser findByPrimaryKey(long userId)
98 throws NoSuchCyrusUserException, SystemException {
99
100 Session session = null;
101
102 try {
103 session = openSession();
104
105 return (CyrusUser)session.load(
106 CyrusUser.class, String.valueOf(userId));
107 }
108 catch (ObjectNotFoundException onfe) {
109 throw new NoSuchCyrusUserException();
110 }
111 catch (Exception e) {
112 throw processException(e);
113 }
114 finally {
115 closeSession(session);
116 }
117 }
118
119 }