YxySendMailDetailDaoImpl.java
4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.espeed.dao.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.espeed.dao.YxySendMailDetailDao;
import com.espeed.pojo.YxySendMailDetail;
import com.espeed.vo.PageBean;
/**
* 程序名称: EspeedMail_时速邮箱
* 程序版本: V1.0
* 作 者: 深圳市科飞时速网络技术有限公司(0755-88843776)
* 版权所有: 深圳市科飞时速网络技术有限公司
* 技术支持: Tech@21gmail.com
* 单元名称: 点读地址DAO实现类(营销游)
* 开始时间: 2013.12.09
* 程 序 员: 谢勇
* 最后修改:
* 备 注: 如需修改请通知程序员
*/
public class YxySendMailDetailDaoImpl extends HibernateBaseDAOImpl<YxySendMailDetail, Long> implements YxySendMailDetailDao{
/**实体插入*/
public int addPojo(YxySendMailDetail o)throws Exception{
return super.add(o);
}
/**实体批量插入*/
public void addPojoPi(List<YxySendMailDetail> list)throws Exception{
if(list.size() > 500){
Session session = super.getHibernateTemplate().getSessionFactory().openSession();
Transaction tx=session.beginTransaction(); //注意用的是hibernate事务处理边界
Connection conn=session.connection();
conn.setAutoCommit(false);
String sql = "INSERT INTO yxy_send_mail_detail(send_mail_id,base_mail_id,receiver,email,email_suffix,variable,company_variable,loginid,domain) " +
"VALUES(?,?,?,?,?,?,?,?,?)";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
for(int i = 0; i < list.size(); i++){
preparedStatement.setInt(1, list.get(i).getSend_mail_id());
preparedStatement.setInt(2, list.get(i).getBase_mail_id());
preparedStatement.setString(3, list.get(i).getReceiver());
preparedStatement.setString(4, list.get(i).getEmail());
preparedStatement.setString(5, list.get(i).getEmail_suffix());
preparedStatement.setString(6, list.get(i).getVariable());
preparedStatement.setString(7, list.get(i).getCompany_variable());
preparedStatement.setString(8, list.get(i).getLoginid());
preparedStatement.setString(9, list.get(i).getDomain());
//"积攒" SQL
preparedStatement.addBatch();
//当 "积攒" 到一定程度, 就统一的执行一次. 并且清空先前 "积攒" 的 SQL
if((i + 1) % 300 == 0){
preparedStatement.executeBatch();
conn.commit();
preparedStatement.clearBatch();
}
}
//若总条数不是批量数值的整数倍, 则还需要再额外的执行一次.
if(list.size() % 300 != 0){
preparedStatement.executeBatch();
conn.commit();
preparedStatement.clearBatch();
}
tx.commit(); //注意用的是hibernate事务处理边界
}else{
super.addPi(list);
}
}
/**实体编辑*/
public void updatePojo(YxySendMailDetail o)throws Exception{
super.update(o);
}
/**HQL查询*/
public List<YxySendMailDetail> findByHql(String hql)throws Exception{
return super.getAll(hql);
}
/**指定条记录*/
public List<YxySendMailDetail> findByHqlSet(String hql,int num)throws Exception{
return super.findBySet(hql, num);
}
/**HQL查询分页*/
public List<YxySendMailDetail> findByHqlPage(String hql,String hqlcount,PageBean pb)throws Exception{
return super.findByPage(hql, hqlcount, pb);
}
/**SQL查询*/
public List<Object> findBySqlQuery(String sql)throws Exception{
return super.findBySql(sql);
}
/**HQL更新*/
public void updateByHql(String hql)throws Exception{
super.updateorDelByHql(hql);
}
/**HQL数量查询*/
public int findByHqlCount(String hql)throws Exception{
return super.count(hql);
}
// /**根据待发邮件ID查询待发地址*/
// public List<YxySendMailDetail> findAddressByMailID(int mailID) throws Exception {
// String hql="from YxySendMailDetail where send_mail_id="+mailID;
// return super.getAll(hql);
// }
// /**修改此地址为已发送*/
// public void updateMailDetailstatus(int addressID) throws Exception {
// String hql="update YxySendMailDetail set status=1 where mail_id="+addressID;
// super.updateorDelBySql(hql);
// }
// /**批量添加地址*/
// public void addMailDetailPi(List<YxySendMailDetail> o) throws Exception {
// super.addPi(o);
// }
//
// /**根据待发邮件ID查询待发地址(基本表)*/
// public List<YxySendMailDetail> findAddressBybaseMailID(int mailID)
// throws Exception {
// String hql="from YxySendMailDetail where base_mail_id="+mailID;
// return super.getAll(hql);
// }
// /**根据邮件ID删除地址*/
// public void delDetailByMailID(int mailID) throws Exception {
// String sql="delete YxySendMailDetail where base_mail_id="+mailID;
// super.updateorDelBySql(sql);
//
// }
}