📄 accountroledaoimpl.java
字号:
package jp.com.cost.dao.impl;
import java.util.List;
import jp.com.cost.common.Log;
import jp.com.cost.dao.AccountroleDao;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
public class AccountroleDaoImpl extends HibernateDaoSupport implements
AccountroleDao {
Query query;
Session session;
public boolean deleteAccountRole(int id) {
// TODO Auto-generated method stub
boolean bln = false;
try {
String SQL = "delete from accountrole where aid=" + id;
session = getHibernateTemplate().getSessionFactory().openSession();
query = session.createSQLQuery(SQL);
query.executeUpdate();
Log.insert("accountRole", "delete");
bln = true;
session.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bln;
}
public boolean addAccountRole(String aid, String[] rid) {
// TODO Auto-generated method stub
boolean bln = false;
for (int i = 0; i < rid.length; i++) {
String SQL = "insert into accountrole(aid,rid) values("
+ Integer.parseInt(aid) + "," + Integer.parseInt(rid[i])
+ ")";
session = getHibernateTemplate().getSessionFactory().openSession();
query = session.createSQLQuery(SQL);
query.executeUpdate();
Log.insert("accountRole", "insert");
bln = true;
session.close();
}
return bln;
}
public boolean updateAccountRole(String aid, String[] rid) {
// TODO Auto-generated method stub
boolean bln = false;
session = getHibernateTemplate().getSessionFactory().openSession();
String SQL1 = "delete from accountrole where aid="
+ Integer.parseInt(aid);
query=session.createSQLQuery(SQL1);
query.executeUpdate();
for (int i = 0; i < rid.length; i++) {
String SQL2 = "insert into accountrole(aid,rid) values("
+ Integer.parseInt(aid) + "," + Integer.parseInt(rid[i])
+ ")";
query=session.createSQLQuery(SQL2);
query.executeUpdate();
}
bln=true;
Log.insert("accountRole", "modify");
session.close();
return bln;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -