?? testdaohibernateimpl.java
字號:
package com.gc.dao.impl;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import com.gc.dao.TestDAOHibernate;
import com.gc.vo.Test;
public class TestDAOHibernateImpl implements TestDAOHibernate {
private Session session = null;
public TestDAOHibernateImpl(Session session) {
this.session = session;
}
public void createTest(Test user) throws SQLException{
session.save(user);
}
public void updateTest(Test user) throws SQLException {
session.update(user);
}
public void deleteTest(Test user) throws SQLException{
session.delete(user);
}
public List queryTest(String name) throws SQLException{
List resultList = new ArrayList();
Test result =new Test();
String sql = "Select * from test where username = :username";
resultList = session.createSQLQuery(sql)
.addEntity("test",Test.class).setString("username", name)
.list();
return resultList;
}
public int createListTest(List list) throws SQLException{
Test user = null;
int counts = 0;
for (int i = 0; list != null && list.size() > i; i++) {
user = (Test)list.get(i);
createTest(user);
counts ++;
}
return counts;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -