很长时间没有用Hibernate了,最近想起,就做了一个简单的增删改查,用到了jQuery的Ajax,同时要考虑在不同的浏览器下实现一样的效果,我分别在谷歌浏览器(版本号7.0.503.0,以下简称GC)、Firefox(版本号3.6.8,以下简称FF)、IE8、GreenBrowser(基于IE7,以下简称GB)下运行,基本功能都已实现,没报什么异常,但现在仔细测试的过程中发现了问题:(1)在谷歌浏览器、FF下执行更新操作后不刷新网页即能看到更新后的内容,而GB则不行,非要刷新后才看得到更新后的内容,发送Ajax请求我也加了时间戳&date=new Date()禁止缓存。这如何解释?
(2)干脆来点彻底的,在每个页面前加上<% response.setDateHeader("Expires", 0);....%>来禁用缓存,更新后GB也能立即看到了,但新的问题也来了(可能在加禁止缓存代码前夜存在,只是没注意),用GC或FF执行更新操作后数据库也更新了,用GB访问,就是看不到更新后的内容(还是更新前的),刷新GB数据库的内容也变成了更新前的,这是什么问题?
(3)我上网查了下Hibernate的load()、get()查询的区别,update()、saveOrUpdate()的异同,也没看出什么,而且各个网站都是抄来抄去,请哪位高手不吝赐教,给我详细讲解讲解(网上抄的不给分)。
(4)帮我看看代码有什么问题,能否再优化,要注意什么,Thanks!

附部分代码:public class BookDAO implements IBook {
private Session session;
private Transaction tx;
private Query query;
public void delete(Book book) {
session = HibernateSessionFactory.getSession();
try {
tx = session.beginTransaction();
session.delete(book);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
} finally {
session.close();
}
} public void save(Book book) {
session = HibernateSessionFactory.getSession();
try {
tx = session.beginTransaction();
session.save(book);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
} finally {
session.close();
}
} public void update(Book book) {
session = HibernateSessionFactory.getSession();
try {
tx = session.beginTransaction();
session.saveOrUpdate(book);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
throw e;
} finally {
session.close();
}
} public Book findBookByISBN(String isbn) {
session = HibernateSessionFactory.getSession();
Book book = (Book) session.get(Book.class, isbn);
return book;
}
}下面是执行更新操作的JS,由于本人讨厌Form表单,所以使用DOM取值。删除、插入操作的JS类似。var date = new Date();
function edit(isbn) {
var name = $('#name').val();
var author = $('#author').val();
var publisher = $('#publisher').val();
var pubdate = $('#pubdate').val();
var bid = $('#bid').val();
var price = $('#price').val();
var introduce = $('#introduce').val();
$.ajax( {
type : 'GET',
url : 'book.do',
dataType : 'text',
global : false,
data : {
method : 'edit',
isbn : isbn,
name : name,
author : author,
publisher : publisher,
pubdate : pubdate,
bid : bid,
price : price,
introduce : introduce,
date : date
},
success : function(data) {
feedback(data);
}
});
}
public ActionForward edit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String isbn = request.getParameter("isbn");
String name = request.getParameter("name");
String author = request.getParameter("author");
String publisher = request.getParameter("publisher");
String introduce = request.getParameter("introduce");
String price = request.getParameter("price");
int bid = Integer.parseInt(request.getParameter("bid"));
String pubdate = request.getParameter("pubdate");
response.setCharacterEncoding("gbk");
try {
out = response.getWriter();
book = dao.findBookByISBN(isbn);
book.setName(name);
book.setAuthor(author);
book.setPrice(price);
book.setPubdate(pubdate);
book.setPublisher(publisher);
book.setIntroduce(introduce);
book.setBookclass(bcd.findById(bid));
dao.update(book);
out.print("更新成功!");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}