如题,请问如何让hibernate不缓存,我的数据会被外部程序实时刷新。谢谢

解决方案 »

  1.   

    听不懂你想干什么
    session.flush();或者在配置文件中(x.hbm.xml)加上dynamic-update=true
    可以试一下不过如果是数据刷新问题的话,那和hibernate无关
    可以再页面头上加
    <meta http-equiv='Expires' content='-10'>
    <meta http-equiv='Pragma' content='No-cache'>
    <meta http-equiv='Cache-Control', 'private'>
    <controller>
    <set-property property="noCache" value="true"/>
    </controller>
    这是加在struts-config.xml里面的
      

  2.   

    晕   刚才回复时CSDN系统居然报以下错误:
    “/”应用程序中的服务器错误。
    --------------------------------------------------------------------------------超时时间已到。在操作完成之前超时时间已过或服务器未响应。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 超时时间已到。在操作完成之前超时时间已过或服务器未响应。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。  堆栈跟踪: 
    [SqlException (0x80131904): 超时时间已到。在操作完成之前超时时间已过或服务器未响应。]
       System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +925466
       System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +800118
       System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +186
       System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1932
       System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
       System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +1005
       System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
       System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +149
       System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
       CSDN.Community.TopicDatabase.TopicDataProvider_PointForum.pointForum_ReplyTopic(ReplyInfo reply, Boolean isLimit, String& ErrInfo, TopicInfo& topic) +1780
       CSDN.Community.PointForum.Services.ReplyTopicManager.ReplyTopic(ReplyInfo reply, DateTime topicPostDate, String& errorInfo, CommunityUser user, UserSectionProfile usp) +562
       CSDN.Community.PointForum.WebControls.ReplyTopicPage.bt_Submit_Click(Object sender, EventArgs e) +603
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746 
    --------------------------------------------------------------------------------
    版本信息: Microsoft .NET Framework 版本:2.0.50727.1433; ASP.NET 版本:2.0.50727.1433 
      

  3.   

    hibernate一级缓存是不能取消滴!
      

  4.   

    session 缓存又不影响你实时访问,二级缓存你不配置它也不会启动啊!
      

  5.   

    默认就是不缓存,你指的1级缓存的话那样如果session关闭了,还有什么1级么
      

  6.   

    使用完session关闭,该session中的一级缓存就失效了。
    如果你在一个session中操作,也可以用session.clear();
    手动消除缓存.
      

  7.   

    session 关闭了,缓存就没了,2 级缓存,你不配置,他是不会自己出来的,再有一个就是系统的缓存。
      

  8.   

    session是Hibernate的内部缓存,除非你不用Hibernate,否则取消不了
      

  9.   

    为什么要不用啊?这是hibernate的一个最大的优点啊
    要想不用每次都用session.clear()试下。清除缓存