| At line 571 changed 1 line. |
| Then create the Hibernate implementation of the interfaces in the src/dao/**/dao/hibernate directory. |
| Then create the Hibernate implementations of the interfaces in the src/dao/**/dao/hibernate directory. |
| At line 602 added 1 line. |
|
| At line 623 added 82 lines. |
| !EntryDAOHibernate |
|
| [{Java2HtmlPlugin |
|
| package org.appfuse.dao.hibernate; |
|
| import java.util.List; |
|
| import org.appfuse.dao.EntryDAO; |
| import org.appfuse.model.Entry; |
| import org.springframework.orm.ObjectRetrievalFailureException; |
|
| public class EntryDAOHibernate extends BaseDaoHibernate implements EntryDAO { |
| |
| public Entry getEntry(Long entryId) { |
| Entry entry = (Entry) getHibernateTemplate().get(Entry.class, entryId); |
|
| if (entry == null) { |
| log.warn("uh oh, weblog '" + entryId + "' not found..."); |
| throw new ObjectRetrievalFailureException(Entry.class, entryId); |
| } |
|
| return entry; |
| } |
|
| public List getEntries(Entry entry) { |
| return getHibernateTemplate().find("from Entry e order by upper(e.timeCreated)"); |
| } |
|
| public void saveEntry(final Entry entry) { |
| getHibernateTemplate().saveOrUpdate(entry); |
| } |
|
| public void removeEntry(Long entryId) { |
| getHibernateTemplate().delete(getEntry(entryId)); |
| } |
|
| } |
|
| }] |
|
| !CategoryDAOHibernate |
|
| [{Java2HtmlPlugin |
|
| package org.appfuse.dao.hibernate; |
|
| import java.util.List; |
|
| import org.appfuse.dao.CategoryDAO; |
| import org.appfuse.model.Category; |
| import org.springframework.orm.ObjectRetrievalFailureException; |
|
| public class CategoryDAOHibernate extends BaseDaoHibernate implements CategoryDAO { |
| |
| public Category getCategory(Long categoryId) { |
| Category category = (Category) getHibernateTemplate().get(Category.class, categoryId); |
|
| if (category == null) { |
| log.warn("uh oh, weblog '" + categoryId + "' not found..."); |
| throw new ObjectRetrievalFailureException(Category.class, categoryId); |
| } |
|
| return category; |
| } |
|
| public List getCategories(Category category) { |
| return getHibernateTemplate().find("from Category cat order by upper(cat.categoryName)"); |
| } |
|
| public void saveCategory(final Category category) { |
| getHibernateTemplate().saveOrUpdate(category); |
| } |
|
| public void removeCategory(Long categoryId) { |
| getHibernateTemplate().delete(getCategory(categoryId)); |
| } |
|
| } |
|
| }] |
|