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