KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > j2biz > blogunity > dao > UserpicDAO


1 /*
2  * $Id: UserpicDAO.java,v 1.4 2005/01/17 21:36:10 michelson Exp $
3  *
4  * Copyright (c) 2004 j2biz Group, http://www.j2biz.com
5  * Koeln / Duesseldorf , Germany
6  *
7  * @author Max Kalina
8  *
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  *
24  */

25
26 package com.j2biz.blogunity.dao;
27
28 import java.io.Serializable JavaDoc;
29
30 import net.sf.hibernate.HibernateException;
31 import net.sf.hibernate.Session;
32
33 import org.apache.commons.logging.Log;
34 import org.apache.commons.logging.LogFactory;
35
36 import com.j2biz.blogunity.exception.BlogunityException;
37 import com.j2biz.blogunity.i18n.I18N;
38 import com.j2biz.blogunity.i18n.I18NStatusFactory;
39 import com.j2biz.blogunity.pojo.Userpic;
40 import com.j2biz.blogunity.util.HibernateUtil;
41
42 /**
43  * @author michelson
44  * @version $$
45  * @since 0.1
46  *
47  *
48  */

49 public class UserpicDAO extends AbstractDAO {
50     /**
51      * Logger for this class
52      */

53     private static final Log log = LogFactory.getLog(UserpicDAO.class);
54
55     /**
56      *
57      */

58     public UserpicDAO() {
59         super();
60     }
61
62     public Userpic getUserpicByID(long id) throws BlogunityException {
63
64         Userpic userpic = getUserpicByID(new Long JavaDoc(id));
65         return userpic;
66     }
67
68     public Userpic getUserpicByID(Long JavaDoc id) throws BlogunityException {
69
70         Session session = HibernateUtil.getSession();
71         Userpic pic = null;
72         try {
73             pic = (Userpic) session.load(Userpic.class, id);
74         } catch (HibernateException ex) {
75             log.error("getUserpicByID(Long)", ex);
76             throw new BlogunityException(I18NStatusFactory.create(I18N.ERRORS.NOT_FOUND_BY_ID,
77                     "Userpic", ex));
78         }
79
80         return pic;
81     }
82
83     public Serializable JavaDoc createUserpic(Userpic pic) throws BlogunityException {
84
85         Session session = HibernateUtil.getSession();
86         try {
87             Serializable JavaDoc returnSerializable = session.save(pic);
88             if (log.isDebugEnabled()) {
89                 log.debug("createUserpic(Userpic) - end");
90             }
91             return returnSerializable;
92         } catch (HibernateException e) {
93             log.error("createUserpic(Userpic)", e);
94             throw new BlogunityException(I18NStatusFactory.create(I18N.ERRORS.CREATE, "Userpic", e));
95         }
96     }
97
98     public void deleteUserpic(Userpic pic) throws BlogunityException {
99
100         Session session = HibernateUtil.getSession();
101         try {
102             session.delete(pic);
103         } catch (HibernateException e) {
104             log.error("deleteUserpic(Userpic)", e);
105             throw new BlogunityException(I18NStatusFactory.create(I18N.ERRORS.DELETE, "Userpic", e));
106         }
107
108     }
109
110     public void updateUserpic(Userpic link) throws BlogunityException {
111
112         Session session = HibernateUtil.getSession();
113         try {
114             session.update(link);
115         } catch (HibernateException e) {
116             log.error("updateUserpic(Userpic)", e);
117             throw new BlogunityException(I18NStatusFactory.create(I18N.ERRORS.UPDATE, "Userpic", e));
118         }
119
120     }
121
122 }
Popular Tags