1 25 26 package com.j2biz.blogunity.dao; 27 28 import java.io.Serializable ; 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 49 public class UserpicDAO extends AbstractDAO { 50 53 private static final Log log = LogFactory.getLog(UserpicDAO.class); 54 55 58 public UserpicDAO() { 59 super(); 60 } 61 62 public Userpic getUserpicByID(long id) throws BlogunityException { 63 64 Userpic userpic = getUserpicByID(new Long (id)); 65 return userpic; 66 } 67 68 public Userpic getUserpicByID(Long 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 createUserpic(Userpic pic) throws BlogunityException { 84 85 Session session = HibernateUtil.getSession(); 86 try { 87 Serializable 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 |