| 1 |
|
package com.neidetcher.petunia.service; |
| 2 |
|
|
| 3 |
|
import org.apache.commons.logging.Log; |
| 4 |
|
import org.apache.commons.logging.LogFactory; |
| 5 |
|
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport; |
| 6 |
|
|
| 7 |
12 |
public class CategoryDaoImpl extends SqlMapClientDaoSupport implements CategoryDao |
| 8 |
|
{ |
| 9 |
|
|
| 10 |
6 |
protected Log log = LogFactory.getLog(CategoryDaoImpl.class); |
| 11 |
|
|
| 12 |
|
@Override |
| 13 |
|
public Category save(Category category) |
| 14 |
|
{ |
| 15 |
6 |
log.debug(category.toString()); |
| 16 |
|
|
| 17 |
6 |
if (category.getId() == null) |
| 18 |
|
{ |
| 19 |
4 |
log.debug("create"); |
| 20 |
|
Integer newId; |
| 21 |
|
|
| 22 |
4 |
newId = (Integer) getSqlMapClientTemplate().insert("Category.insert", category); |
| 23 |
4 |
category.setId(newId); |
| 24 |
4 |
return category; |
| 25 |
|
} |
| 26 |
|
|
| 27 |
2 |
log.debug("update"); |
| 28 |
2 |
getSqlMapClientTemplate().update("Category.update", category, 1); |
| 29 |
2 |
return category; |
| 30 |
|
} |
| 31 |
|
|
| 32 |
|
public Category find(Integer id) |
| 33 |
|
{ |
| 34 |
2 |
return (Category) getSqlMapClientTemplate().queryForObject("Category.findById", id); |
| 35 |
|
} |
| 36 |
|
} |