常用的存取修改
比如save(Object obj)
update(Object obj)
delete(Object obj)

解决方案 »

  1.   

    还有    
          
          Object find(...)
      

  2.   

    谢谢!我的意思是放在任何项目都能使用的dao框架,能够将数据与业务逻辑完全分开的。
      

  3.   

    用hibernate,外面封一个DAO,可以很通用,基本的insert、update可以很通用。
    给你一段演示:  public static Object findByID(Class myClass, Serializable id) throws
          Exception {
        Object obj = null;
        Session s = currentSession();
        try {
          obj = s.load(myClass, id);
        }
        catch (ObjectNotFoundException oe) {
          obj = null;
        }
        catch (HibernateException he) {
          logger.error(
              "HibernateException thrown in HiSessionFunctions.FindByID(): " + he);
          throw (Exception) he;
        }
        return obj;
      }  public static Object insert(Object obj) throws Exception {
        Session s = currentSession();
        Transaction tx = null;
        try {
          tx = s.beginTransaction();
          s.save(obj);
          tx.commit();
        }
        catch (HibernateException he) {
          if (tx != null) {
            tx.rollback();
          }
          logger.error("HibernateException thrown in HiSessionFunctions.Insert(): " +
                       he);
          throw (Exception) he;
        }
        s.flush();
        return obj;
      }
      

  4.   

    推荐Spring+Hibernate,前者是一个AOP 框架和IOC 容器,后者是一个对象关系映射工具,结合这两者,为应用程序构建事务持久层