⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 angexchangevisithibernatedao.java~128~

📁 hibernate+spring的相片上传项目
💻 JAVA~128~
字号:
package org.lenovoAC.hibernateDao;

import org.lenovoAC.pojo.AngExchangeVisit;
import java.util.List;
import org.lenovoAC.dao.AngExchangeVisitDao;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Connection;
import net.sf.hibernate.Session;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *安保互动
  安保互动表: Ang_exchange_visits

 * @author not attributable
 * @version 1.0
 */
public class AngExchangeVisitHibernateDao
    extends BaseDao
{
  /**
   *添加
   * @param aev AngExchangeVisit
   */
  public void insertAEV(AngExchangeVisit aev)
      throws Exception
  {
    this.getHibernateTemplate().save(aev);

    Connection con= null;
    ResultSet rs=null;
    Session session=this.getSession();
    con=session.connection();
    con.setAutoCommit(false);
    String sql="select * from ANG_EXCHANGE_VISITS where id='"+aev.getId()+"' for update";
    PreparedStatement ps = con.prepareStatement(sql);
    rs=ps.executeQuery();
    if(rs.next())
    {
      oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CONTEXT");
      java.io.Writer out=clob.getCharacterOutputStream();
      out.write(aev.getContext());
      out.close();
      con.commit();
      con.close();
    }

  }

  /**
   * 修改
   * @param aev AngExchangeVisit
   */
  public void upateAEV(AngExchangeVisit aev)
      throws Exception
  {
    /*net.sf.hibernate.Session session=null;
    java.sql.PreparedStatement ps=null;
    java.sql.Connection con=null;
    try
    {
      String sql="update ANG_EXCHANGE_VISITS set Title=?,Context=?,time=sysdate,State=? where id=?";
      session=this.getSession();
      con=session.connection();
      ps=con.prepareStatement(sql);
      ps.setString(1,aev.getTitle());
      ps.setString(2,aev.getContext());
      ps.setString(3,aev.getState());
      ps.setString(4,aev.getId());
      ps.executeUpdate();
      ps.close();
      con.close();
      session.close();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }*/

  Connection con= null;
  ResultSet rs=null;
  Session session=this.getSession();
  con=session.connection();
  con.setAutoCommit(false);

  String sqlTwo="update ANG_EXCHANGE_VISITS set Title=?,Context=?,time=sysdate,State=? where id=?";
  PreparedStatement ps2 = con.prepareStatement(sqlTwo);


  String sql="select * from ANG_EXCHANGE_VISITS where id='"+aev.getId()+"' for update";
  PreparedStatement ps = con.prepareStatement(sql);
  rs=ps.executeQuery();
  if(rs.next())
  {
    oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob("CONTEXT");
    java.io.Writer out=clob.getCharacterOutputStream();
    out.write(aev.getContext());
    out.close();
    con.commit();
    con.close();
  }

  }

  /**
   * 删除
   * @param aev AngExchangeVisit
   */
  public void delAEV(AngExchangeVisit aev)
  {
    this.getHibernateTemplate().delete(aev);
  }

  /**
   * 得到指定单个实例
   * @param id String
   * @return AngExchangeVisit
   */
  public AngExchangeVisit getAEV(String id)
  {
    return (AngExchangeVisit)this.getHibernateTemplate().load(AngExchangeVisit.class,
        id);
  }

  /**
   * 删除指定ID的对象
   * @param id String
   */
  public void delAEVTwo(String id)
  {
    AngExchangeVisit aev = this.getAEV(id);
    this.delAEV(aev);
  }

  /**
   * 修改指定ID的值为aevOld传入的值
   * @param id String
   * @param aevOld AngExchangeVisit
   */
  public void updateAEVTwo(String id, AngExchangeVisit aevOld)
      throws Exception
  {
    AngExchangeVisit aevNew = this.getAEV(id);
    aevNew.setTitle(aevOld.getTitle());
    aevNew.setContext(aevOld.getContext());
    aevNew.setTime(aevOld.getTime());
    aevNew.setState(aevOld.getState());
    this.upateAEV(aevNew);
  }

  /**
   * 得到所有实例
   * @return List
   */
  public List getAllAEV()
  {
    return this.getHibernateTemplate().loadAll(AngExchangeVisit.class);
  }

  /**
   * 得到所有实例(根据时间排序)
   * @return List
   */
  public List getAllAEVTwo()
  {
    String hql = "from AngExchangeVisit as aev order by aev.time desc";
    return this.getHibernateTemplate().find(hql);
  }

  /**
   * 得到指定实例状态值
   * @param id String
   * @return String
   */
  public String getState(String id)
  {
    AngExchangeVisit aev = this.getAEV(id);
    return aev.getState();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -