|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
最后更新时间:2005-01-12
[code:1]
package oa.service; import oa.pojo.*; import java.util.Iterator; import java.util.Date; import common.spring.dao.*; import common.spring.pojo.*; import net.sf.hibernate.*; import org.springframework.orm.hibernate.support.*; import java.util.List; /** * <p>Title: OA1.0</p> * * <p>Description: </p> * * <p>Copyright: Copyright (c) 2004</p> * * <p>Company: </p> * * @author 段洪杰 * @version 1.0 */ public class PersonalServiceSpringImpl implements IPersonalService { private IBaseDAO baseDAO; /** 初始化域 */ Class planService = new Plan().getClass(); Class cardService = new Card().getClass(); Class userService = new User().getClass(); Class noteService = new Note().getClass(); Class faxService = new Fax().getClass(); Class fastService = new Fast().getClass(); /** * 根据取用户信息列表 * @param position int * @param length int * @return Iterator * @throws PersonalServiceException */ public Iterator getUsers(int position, int length) throws PersonalServiceException { Iterator users = null; baseDAO.init(userService); try { users = (Iterator) baseDAO.getObjects( position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return users; } /** * 根据个人注册名取用户信息列表总数 * @return int * @throws PersonalServiceException */ public int getUsersCount() throws PersonalServiceException { int count = 0; baseDAO.init(userService); try { count = baseDAO.getObjectsCount(); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 根据个人注册名取一条记录 * @param registerName String * @return User * @throws PersonalServiceException */ public User getUserByRegisterName(String registerName) throws PersonalServiceException { User user = null; baseDAO.init(userService); try { user = (User) baseDAO.getObjectByRegisterName(registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return user; } /** * 根据ID取用户信息 * @return User * @throws PersonalServiceException */ public User getUserById(String id) throws PersonalServiceException { User user = null; baseDAO.init(userService); try { user = (User) baseDAO.getObjectById(id); } catch (Exception ex) { throw new PersonalServiceException(ex); } return user; } /** * 根据ID删除用户信息 * @param id String * @throws PersonalServiceException */ public void removeUserById(String id) throws PersonalServiceException { baseDAO.init(userService); try { baseDAO.removeObject(baseDAO.getObjectById(id)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 修改用户信息 * @param user User * @throws PersonalServiceException */ public void modifyUser(User user) throws PersonalServiceException { baseDAO.init(userService); try { baseDAO.modifyObject(user); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据ID和注册名取用户信息 * @param id String * @param registerName String * @return User * @throws PersonalServiceException */ public User getUserByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { User user = null; baseDAO.init(userService); try { user = (User) baseDAO.getObjectByIdAndRegisterName(id, registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return user; } /** * 根据ID和注册名删除用户信息 * @param id String * @param registerName String * @throws PersonalServiceException */ public void removeUserByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { baseDAO.init(userService); try { baseDAO.removeObject(baseDAO.getObjectByIdAndRegisterName(id, registerName)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 录入用户信息 * @param user User * @throws PersonalServiceException */ public void setUser(User user) throws PersonalServiceException { baseDAO.init(userService); try { baseDAO.setObject(user); } catch (Exception ex) { throw new PersonalServiceException(ex); } } //////////////////////////////////// /** * 根据个人注册名取个人计划列表 * @param registerName String * @param position int * @param length int * @return Iterator * @throws PersonalServiceException */ public Iterator getPlansByRegisterName(String registerName, int position, int length) throws PersonalServiceException { Iterator plans = null; baseDAO.init(planService); try { plans = (Iterator) baseDAO.getObjectsByRegisterName(registerName, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return plans; } /** * 根据个人注册名取个人计划列表总数 * @param registerName String * @return int * @throws PersonalServiceException */ public int getPlansCountByRegisterName(String registerName) throws PersonalServiceException { int count = 0; baseDAO.init(planService); try { count = baseDAO.getObjectsCountByRegisterName(registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 根据ID取个人计划 * @return Plan * @throws PersonalServiceException */ public Plan getPlanById(String id) throws PersonalServiceException { Plan plan = null; baseDAO.init(planService); try { plan = (Plan) baseDAO.getObjectById(id); } catch (Exception ex) { throw new PersonalServiceException(ex); } return plan; } /** * 根据ID删除计划 * @throws PersonalServiceException */ public void removePlanById(String id) throws PersonalServiceException { baseDAO.init(planService); try { baseDAO.removeObject(baseDAO.getObjectById(id)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 修改计划 * @param plan Plan * @throws PersonalServiceException */ public void modifyPlan(Plan plan) throws PersonalServiceException { baseDAO.init(planService); try { baseDAO.modifyObject(plan); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据ID和注册名取计划 * @param id String * @param registerName String * @return Plan * @throws PersonalServiceException */ public Plan getPlanByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { Plan plan = null; baseDAO.init(planService); try { plan = (Plan) baseDAO.getObjectByIdAndRegisterName(id, registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return plan; } /** * 根据ID和注册名删除计划 * @param id String * @param registerName String * @throws PersonalServiceException */ public void removePlanByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { baseDAO.init(planService); try { baseDAO.removeObject(baseDAO.getObjectByIdAndRegisterName(id, registerName)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 录入计划 * @param plan Plan * @throws PersonalServiceException */ public void setPlan(Plan plan) throws PersonalServiceException { baseDAO.init(planService); try { baseDAO.setObject(plan); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据注册名和到期时间取数据 * @param outDate Date * @param registerName String * @return Plan * @throws PersonalServiceException */ public Plan getPlan(Date outDate, String registerName) throws PersonalServiceException { String hql = "Select Plan as plan where plan.registerName and plan.outDate=:date order by plan.createDate desc"; Iterator plans = null; Plan plan = null; try { plans = (Iterator) baseDAO.find(hql, outDate, 0, 1); } catch (Exception ex) { throw new PersonalServiceException(ex); } while (plans.hasNext()) { plan = (Plan) plans.next(); } return plan; } /** * 查询到Plan的记录总数 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public int searchPlanCountByRegisterName(String registerName, String text) throws PersonalServiceException { int count = 0; try { String hql = "select Plan as plan where plan.registerName ='" + registerName + "' and plan.title like '%" + text + "%'"; count = baseDAO.count(hql); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 查询到Plan的记录 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public Iterator searchPlanByRegisterName(String registerName, String text, int position, int length) throws PersonalServiceException { Iterator plans = null; try { String hql = "select Plan as plan where plan.registerName ='" + registerName + "' and plan.title like '%" + text + "%' order by plan.createDate"; plans = baseDAO.find(hql, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return plans; } //////////////////////////////////////////////////////////////////// /** * 列出用户的个人名片 * @param registerName String * @param position int * @param length int * @return Iterator * @throws PersonalServiceException */ public Iterator getCardsByRegisterName(String registerName, int position, int length) throws PersonalServiceException { Iterator cards = null; baseDAO.init(cardService); try { cards = (Iterator) baseDAO.getObjectsByRegisterName(registerName, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return cards; } /** * 显示个人用户名片夹的数目 * @param registerName String * @return int * @throws PersonalServiceException */ public int getCardsCountByRegisterName(String registerName) throws PersonalServiceException { int count = 0; baseDAO.init(cardService); try { count = baseDAO.getObjectsCountByRegisterName(registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 根据ID显示名片 * @return Card * @throws PersonalServiceException */ public Card getCardById(String id) throws PersonalServiceException { Card card = null; baseDAO.init(cardService); try { card = (Card) baseDAO.getObjectById(id); } catch (Exception ex) { throw new PersonalServiceException(ex); } return card; } /** * 根据ID删除名片 * @throws PersonalServiceException */ public void removeCardById(String id) throws PersonalServiceException { baseDAO.init(cardService); try { baseDAO.removeObject(baseDAO.getObjectById(id)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 修改名片 * @param card Card * @throws PersonalServiceException */ public void modifyCard(Card card) throws PersonalServiceException { baseDAO.init(cardService); try { baseDAO.modifyObject(card); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据ID和注册名取名片 * @param id String * @param registerName String * @return Card * @throws PersonalServiceException */ public Card getCardByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { Card card = null; baseDAO.init(cardService); try { card = (Card) baseDAO.getObjectByIdAndRegisterName(id, registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return card; } /** * 根据ID和注册名删除名片 * @param id String * @param registerName String * @throws PersonalServiceException */ public void removeCardByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { baseDAO.init(cardService); try { baseDAO.removeObject(baseDAO.getObjectByIdAndRegisterName(id, registerName)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 录入名片 * @param card Card * @throws PersonalServiceException */ public void setCard(Card card) throws PersonalServiceException { baseDAO.init(cardService); try { baseDAO.setObject(card); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 查询到Card的记录总数 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public int searchCardCountByRegisterName(String registerName, String text) throws PersonalServiceException { int count = 0; try { String hql = "select Card as card where card.registerName ='" + registerName + "' and card.title like '%" + text + "%'"; count = baseDAO.count(hql); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 查询到Card的记录 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public Iterator searchCardByRegisterName(String registerName, String text, int position, int length) throws PersonalServiceException { Iterator cards = null; try { String hql = "select Card as card where card.registerName ='" + registerName + "' and card.title like '%" + text + "%' order by card.createDate"; cards = baseDAO.find(hql, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return cards; } ///////////////////////////////////////////////// /** * 根据个人注册名取个人记事本列表 * @param registerName String * @param position int * @param length int * @return Iterator * @throws PersonalServiceException */ public Iterator getNotesByRegisterName(String registerName, int position, int length) throws PersonalServiceException { Iterator notes = null; baseDAO.init(noteService); try { notes = (Iterator) baseDAO.getObjectsByRegisterName(registerName, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return notes; } /** * 根据个人注册名取个人记事本列表总数 * @param registerName String * @return int * @throws PersonalServiceException */ public int getNotesCountByRegisterName(String registerName) throws PersonalServiceException { int count = 0; baseDAO.init(noteService); try { count = baseDAO.getObjectsCountByRegisterName(registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 根据ID取个人记事本 * @return Note * @throws PersonalServiceException */ public Note getNoteById(String id) throws PersonalServiceException { Note note = null; baseDAO.init(noteService); try { note = (Note) baseDAO.getObjectById(id); } catch (Exception ex) { throw new PersonalServiceException(ex); } return note; } /** * 根据ID删除记事本 * @throws PersonalServiceException */ public void removeNoteById(String id) throws PersonalServiceException { baseDAO.init(noteService); try { baseDAO.removeObject(baseDAO.getObjectById(id)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 修改记事本 * @param note Note * @throws PersonalServiceException */ public void modifyNote(Note note) throws PersonalServiceException { baseDAO.init(noteService); try { baseDAO.modifyObject(note); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据ID和注册名取记事本 * @param id String * @param registerName String * @return Note * @throws PersonalServiceException */ public Note getNoteByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { Note note = null; baseDAO.init(noteService); try { note = (Note) baseDAO.getObjectByIdAndRegisterName(id, registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return note; } /** * 根据ID和注册名删除记事本 * @param id String * @param registerName String * @throws PersonalServiceException */ public void removeNoteByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { baseDAO.init(noteService); try { baseDAO.removeObject(baseDAO.getObjectByIdAndRegisterName(id, registerName)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 录入记事本 * @param note Note * @throws PersonalServiceException */ public void setNote(Note note) throws PersonalServiceException { baseDAO.init(noteService); try { baseDAO.setObject(note); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 查询到Note的记录总数 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public int searchNoteCountByRegisterName(String registerName, String text) throws PersonalServiceException { int count = 0; try { String hql = "select Note as note where note.registerName ='" + registerName + "' and note.title like '%" + text + "%'"; count = baseDAO.count(hql); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 查询到Note的记录 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public Iterator searchNoteByRegisterName(String registerName, String text, int position, int length) throws PersonalServiceException { Iterator notes = null; try { String hql = "select Note as note where note.registerName ='" + registerName + "' and note.title like '%" + text + "%' order by note.createDate"; notes = baseDAO.find(hql, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return notes; } //////////////////////////////////// /** * 根据个人注册名取个人电话传真记录列表 * @param registerName String * @param position int * @param length int * @return Iterator * @throws PersonalServiceException */ public Iterator getFaxsByRegisterName(String registerName, int position, int length) throws PersonalServiceException { Iterator faxs = null; baseDAO.init(faxService); try { faxs = (Iterator) baseDAO.getObjectsByRegisterName(registerName, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return faxs; } /** * 根据个人注册名取个人电话传真记录列表总数 * @param registerName String * @return int * @throws PersonalServiceException */ public int getFaxsCountByRegisterName(String registerName) throws PersonalServiceException { int count = 0; baseDAO.init(faxService); try { count = baseDAO.getObjectsCountByRegisterName(registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 根据ID取个人电话传真记录 * @return Fax * @throws PersonalServiceException */ public Fax getFaxById(String id) throws PersonalServiceException { Fax fax = null; baseDAO.init(faxService); try { fax = (Fax) baseDAO.getObjectById(id); } catch (Exception ex) { throw new PersonalServiceException(ex); } return fax; } /** * 根据ID删除电话传真记录 * @throws PersonalServiceException */ public void removeFaxById(String id) throws PersonalServiceException { baseDAO.init(faxService); try { baseDAO.removeObject(baseDAO.getObjectById(id)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 修改电话传真记录 * @param fax Fax * @throws PersonalServiceException */ public void modifyFax(Fax fax) throws PersonalServiceException { baseDAO.init(faxService); try { baseDAO.modifyObject(fax); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据ID和注册名取电话传真记录 * @param id String * @param registerName String * @return Fax * @throws PersonalServiceException */ public Fax getFaxByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { Fax fax = null; baseDAO.init(faxService); try { fax = (Fax) baseDAO.getObjectByIdAndRegisterName(id, registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return fax; } /** * 根据ID和注册名删除电话传真记录 * @param id String * @param registerName String * @throws PersonalServiceException */ public void removeFaxByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { baseDAO.init(faxService); try { baseDAO.removeObject(baseDAO.getObjectByIdAndRegisterName(id, registerName)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 录入电话传真记录 * @param fax Fax * @throws PersonalServiceException */ public void setFax(Fax fax) throws PersonalServiceException { baseDAO.init(faxService); try { baseDAO.setObject(fax); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 查询到Fax的记录总数 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public int searchFaxCountByRegisterName(String registerName, String text) throws PersonalServiceException { int count = 0; try { String hql = "select Fax as fax where fax.registerName ='" + registerName + "' and fax.title like '%" + text + "%'"; count = baseDAO.count(hql); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 查询到Fax的记录 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public Iterator searchFaxByRegisterName(String registerName, String text, int position, int length) throws PersonalServiceException { Iterator faxs = null; try { String hql = "select Fax as fax where fax.registerName ='" + registerName + "' and fax.title like '%" + text + "%' order by fax.createDate"; faxs = baseDAO.find(hql, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return faxs; } //////////////////////////////////// /** * 根据个人注册名取个人特快专递列表 * @param registerName String * @param position int * @param length int * @return Iterator * @throws PersonalServiceException */ public Iterator getFastsByRegisterName(String registerName, int position, int length) throws PersonalServiceException { Iterator fasts = null; baseDAO.init(fastService); try { fasts = (Iterator) baseDAO.getObjectsByRegisterName(registerName, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return fasts; } /** * 根据个人注册名取个人特快专递列表总数 * @param registerName String * @return int * @throws PersonalServiceException */ public int getFastsCountByRegisterName(String registerName) throws PersonalServiceException { int count = 0; baseDAO.init(fastService); try { count = baseDAO.getObjectsCountByRegisterName(registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 根据ID取个人特快专递 * @return Fast * @throws PersonalServiceException */ public Fast getFastById(String id) throws PersonalServiceException { Fast fast = null; baseDAO.init(fastService); try { fast = (Fast) baseDAO.getObjectById(id); } catch (Exception ex) { throw new PersonalServiceException(ex); } return fast; } /** * 根据ID删除特快专递 * @throws PersonalServiceException */ public void removeFastById(String id) throws PersonalServiceException { baseDAO.init(fastService); try { baseDAO.removeObject(baseDAO.getObjectById(id)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 修改特快专递 * @param fast Fast * @throws PersonalServiceException */ public void modifyFast(Fast fast) throws PersonalServiceException { baseDAO.init(fastService); try { baseDAO.modifyObject(fast); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 根据ID和注册名特快专递 * @param id String * @param registerName String * @return Fast * @throws PersonalServiceException */ public Fast getFastByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { Fast fast = null; baseDAO.init(fastService); try { fast = (Fast) baseDAO.getObjectByIdAndRegisterName(id, registerName); } catch (Exception ex) { throw new PersonalServiceException(ex); } return fast; } /** * 根据ID和注册名特快专递 * @param id String * @param registerName String * @throws PersonalServiceException */ public void removeFastByIdAndRegisterName(String id, String registerName) throws PersonalServiceException { baseDAO.init(fastService); try { baseDAO.removeObject(baseDAO.getObjectByIdAndRegisterName(id, registerName)); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 录入特快专递 * @param fast Fast * @throws PersonalServiceException */ public void setFast(Fast fast) throws PersonalServiceException { baseDAO.init(fastService); try { baseDAO.setObject(fast); } catch (Exception ex) { throw new PersonalServiceException(ex); } } /** * 查询到Fast的记录总数 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public int searchFastCountByRegisterName(String registerName, String text) throws PersonalServiceException { int count = 0; try { String hql = "select Fast as fast where fast.registerName ='" + registerName + "' and fast.title like '%" + text + "%'"; count = baseDAO.count(hql); } catch (Exception ex) { throw new PersonalServiceException(ex); } return count; } /** * 查询到Fast的记录 * @param registerName String * @param text String * @return int * @throws PersonalServiceException */ public Iterator searchFastByRegisterName(String registerName, String text, int position, int length) throws PersonalServiceException { Iterator fasts = null; try { String hql = "select Fast as fast where fast.registerName ='" + registerName + "' and fast.title like '%" + text + "%' order by fast.createDate"; fasts = baseDAO.find(hql, position, length); } catch (Exception ex) { throw new PersonalServiceException(ex); } return fasts; } /////////////////////////////////////////////////// public void setBaseDAO(IBaseDAO baseDAO) { this.baseDAO = baseDAO; } public IBaseDAO getBaseDAO() { return baseDAO; } } [/code:1] 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
你到底想说啥呢?
|
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
引用 /** 初始化域 */
Class planService = new Plan().getClass(); Class cardService = new Card().getClass(); Class userService = new User().getClass(); Class noteService = new Note().getClass(); Class faxService = new Fax().getClass(); Class fastService = new Fast().getClass(); 超怪的写法......哈哈......还有就是同gigx |
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
可能想说这个行数太多
|
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
和
Class planService = Plan.class; Class cardService = Card.class; 有什么不同? xiaoyu 写道 引用 /** 初始化域 */
Class planService = new Plan().getClass(); Class cardService = new Card().getClass(); Class userService = new User().getClass(); Class noteService = new Note().getClass(); Class faxService = new Fax().getClass(); Class fastService = new Fast().getClass(); 超怪的写法......哈哈......还有就是同gigx |
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
你加上-verbose来看一下.
[code:1]public class TestClass{ public TestClass(){ System.out.println("create...."); new TestClass(); } public static void main(String[] args){ //Class clazz=TestClass.class; Class clazz=new TestClass().getClass(); } }[/code:1] 调用这个代码呢? |
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
老段又来吓人了.....
IBaseDAO仍然是个超大型的类 |
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
下面的代码一般用不到,所以刚看到会觉得怪. 但是我做了一个通用的DAO类, SQL是自动拼出来的.表名是动态的,通过下面的代码就取得表名了,在HIBERNATE中,一个表对应一个类PO.
这样搞出来的表名字串不容易写错, 如果直接定义个String,程序写长时间了就会是什么名字也想不起来了. <code> Class planService = new Plan().getClass(); Class cardService = new Card().getClass(); Class userService = new User().getClass(); Class noteService = new Note().getClass(); Class faxService = new Fax().getClass(); Class fastService = new Fast().getClass(); </code> |
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
flyingbug 写道 老段又来吓人了.....
IBaseDAO仍然是个超大型的类 吓人不敢,学习是真......... IBaseDAO确实是超大的类,虽然可以简化小类. 但是IBaseDAO中有很多数据库的较通用的操作方法,可以当成API调用,所以也不打算简化. |
|
| 返回顶楼 | |
|
最后更新时间:2005-01-12
这个Service太大,因为在这里面有对五、六个表的操作。
我曾作过抽象,结果不行的。SERVICE在SPRING中是一个单例。 抽象象之后,对一个表操作后,操作另一个表时,还是前一个表的数据。 如果把这个service分成五、六个类,就不是SERVICE层了。这层是业务逻辑层,在一些系统中,很多表的数据交互和处理是要在这里的。 |
|
| 返回顶楼 | |












