| At line 1733 added 1 line. |
| [{Java2HtmlPlugin |
| At line 1735 added 1 line. |
| package org.appfuse.dao; |
| At line 1737 added 18 lines. |
| import java.util.List; |
|
| import org.appfuse.model.Weblog; |
|
| public interface WeblogDAO extends Dao{ |
| |
| public Weblog getWeblog(Long weblogId); |
| |
| public List getWeblogs(Weblog weblog); |
| |
| public void saveWeblog(Weblog weblog); |
|
| public void removeWeblog(Long weblogId); |
|
| } |
|
| }] |
|
| At line 1757 added 1 line. |
| [{Java2HtmlPlugin |
| At line 1759 added 63 lines. |
| package org.appfuse.dao.hibernate; |
|
| import java.util.List; |
|
| import org.appfuse.dao.WeblogDAO; |
| import org.appfuse.model.Weblog; |
| import org.springframework.orm.ObjectRetrievalFailureException; |
|
| /** |
| * This class interacts with Spring's HibernateTemplate to save/delete and |
| * retrieve Weblog objects. |
| * |
| * <p> |
| * <a href="WeblogDAOHibernate.java.html"><i>View Source</i></a> |
| * </p> |
| * |
| */ |
| public class WeblogDAOHibernate extends BaseDaoHibernate implements WeblogDAO { |
| |
| public Weblog getWeblog(Long weblogId) { |
| Weblog weblog = (Weblog) getHibernateTemplate().get(Weblog.class, weblogId); |
|
| if (weblog == null) { |
| log.warn("uh oh, weblog '" + weblogId + "' not found..."); |
| throw new ObjectRetrievalFailureException(Weblog.class, weblogId); |
| } |
|
| return weblog; |
| } |
|
| /** |
| * @see org.appfuse.dao.WeblogDAO#getWeblogs(org.appfuse.model.Weblog) |
| */ |
| public List getWeblogs(Weblog weblog) { |
| return getHibernateTemplate().find("from Weblog wl order by upper(wl.blogTitle)"); |
| } |
|
| /** |
| * @see org.appfuse.dao.WeblogDAO#saveWeblog(org.appfuse.model.Weblog) |
| */ |
| public void saveWeblog(final Weblog weblog) { |
| if (log.isDebugEnabled()) { |
| log.debug("weblog's title: " + weblog.getBlogTitle()); |
| } |
| |
| getHibernateTemplate().saveOrUpdate(weblog); |
| // necessary to throw a DataIntegrityViolation and catch it in WeblogManager |
| getHibernateTemplate().flush(); |
| } |
|
| /** |
| * @see org.appfuse.dao.WeblogDAO#removeWeblog(java.lang.String) |
| */ |
| public void removeWeblog(Long weblogId) { |
| Weblog weblog = getWeblog(weblogId); |
| getHibernateTemplate().delete(weblog); |
| } |
|
| } |
|
| }] |
|
|