📄 e0d019f42d9a001b18abbf5fd3239213
字号:
package com.tangjun.data.impl;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.HibernateTemplate;
import com.tangjun.data.ICDDao;
import com.tangjun.data.hibernate.HibernateSessionFactory;
import com.tangjun.model.exception.MyException;
import com.tangjun.web.pojo.CD;
public class CDDaoImpl implements ICDDao
{
public enum Action
{
Add,Delete,Update,Select,SelectAll
}
public CDDaoImpl()
{
}
public boolean addCD(CD cd)
{
Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
session.save(cd);
tx.commit();
session.close();
return true;
}
public boolean delCD(Integer id)
{
Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
CD cd = (CD)session.load(CD.class,id);
session.delete(cd);
tx.commit();
session.close();
return true;
}
public boolean updateCD(CD cd)
{
Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
session.update(cd);
tx.commit();
session.close();
return true;
}
public CD findCDById(Integer id)
{
Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
CD cd = (CD)session.load(CD.class,id);
session.delete(cd);
tx.commit();
session.close();
return cd;
}
public List getAllCD() throws MyException
{
String hql = "from CD c";
try
{
List cds = null; // = this.getHibernateTemplate().find(hql);
return cds;
}
catch(Exception e)
{
throw new MyException(e.getMessage());
}
// return ht.find("from cd c");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -