请问一下在ibatis3.0中如何做到对象缓存同步。 例如:我在程序的两条线程中同时查询一条信息。如何才能做到查询出来的映射对象是同一个。及hashcode相同。
如:
public class BookDao implements BookMapper { public Book selectBook(Book book) {
SqlSession session = null;
try {
session = LibraryServer.sessionFactory.openSession();
BookMapper bookMap = session.getMapper(BookMapper.class);
book = bookMap.selectBook(book);
} finally {
session.close();
}
return book;
} public static void main(String[] s){
BookDao bookDao = new BookDao();
Book book = new Book();
book.setBookID(1);
Book book1 = bookDao.selectBook(book);
Book book2 = bookDao.selectBook(book);
System.out.println(book1.hashCode());
System.out.println(book2.hashCode());
}
}
在xml中这样配置的
  <?xml version="1.0" encoding="UTF-8" ?> 
  <!DOCTYPE mapper (View Source for full doctype...)> 
- <!--   
  --> 
- <mapper namespace="cn.bbt.server.mapper.BookMapper">
  <select id="selectBook" parameterType="cn.bbt.server.entity.Book" resultType="cn.bbt.server.entity.Book" flushCache="true" useCache="true">select id as 'bookID',name as 'bookName',outDate as 'borrowOutDate',returnDate as 'returnBookDate',onLibrary as 'onLibrary' from book where id = #{bookID}</select> 
  </mapper>
中怎样才能使book1和book2的为同一个对象。 在book表中Id为主键
在ibatis3.0 使用文档中只有一个cache标签。使用了没反应。在2.0中有个cacheMude能够设置
3.0却没有找。麻烦给我达人帮我看看