Hibernate 使用注意点
1,要注意 session 的 flushmode,例如,如果 flush mode 为 commit,即 commit 才会 flush,那么程序中先改后查就会变成先查后改;
2,使用 OpenSessionInViewInterceptor,会将 flush mode 设为 manual,如果数据库操作不在事务里面,session 就不会 flush,但是其他操作(增删查)如常;
Hibernate 使用注意点1,要注意 session 的 flushmode,例如,如果 flush mode 为 commit,即 commit 才会 flush,那么程序中先改后查就会变成先查后改; 2,使用 OpenSessionInViewInterceptor,会将 flush mode 设为 manual,如果数据库操作不在事务里面,session 就不会 flush,但是其他操作(增删查)如常;
|