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
37 public class CyrusUserPersistence extends BasePersistenceImpl {
38
39 public void remove(long userId)
40 throws NoSuchCyrusUserException, SystemException {
41
42 Session session = null;
43
44 try {
45 session = openSession();
46
47 CyrusUser user = (CyrusUser)session.load(
48 CyrusUser.class, String.valueOf(userId));
49
50 session.delete(user);
51
52 session.flush();
53 }
54 catch (ObjectNotFoundException onfe) {
55 throw new NoSuchCyrusUserException();
56 }
57 catch (Exception e) {
58 throw processException(e);
59 }
60 finally {
61 closeSession(session);
62 }
63 }
64
65 public void update(CyrusUser user) throws SystemException {
66 Session session = null;
67
68 try {
69 session = openSession();
70
71 try {
72 CyrusUser userModel = (CyrusUser)session.load(
73 CyrusUser.class, String.valueOf(user.getUserId()));
74
75 userModel.setPassword(user.getPassword());
76
77 session.flush();
78 }
79 catch (ObjectNotFoundException onfe) {
80 CyrusUser userModel = new CyrusUser(
81 user.getUserId(), user.getPassword());
82
83 session.save(userModel);
84
85 session.flush();
86 }
87 }
88 catch (Exception e) {
89 throw processException(e);
90 }
91 finally {
92 closeSession(session);
93 }
94 }
95
96 public CyrusUser findByPrimaryKey(long userId)
97 throws NoSuchCyrusUserException, SystemException {
98
99 Session session = null;
100
101 try {
102 session = openSession();
103
104 return (CyrusUser)session.load(
105 CyrusUser.class, String.valueOf(userId));
106 }
107 catch (ObjectNotFoundException onfe) {
108 throw new NoSuchCyrusUserException();
109 }
110 catch (Exception e) {
111 throw processException(e);
112 }
113 finally {
114 closeSession(session);
115 }
116 }
117
118 }