并发更新期间的 Hibernate StaleObjectStateException

2023-12-14

我在 Java J2EE Web 应用程序中使用 Hibernate 3.5.2 和 Spring Core 3.0.1。当不同的用户同时更新同一记录时,我收到 StaleObjectStateExcpetion 。事务由 javax.persistence.EntityManager 管理。以下是我创建问题所采取的步骤。

  1. User1 登录应用程序
  2. User2 登录应用程序
  3. User1开始编辑recordS
  4. User2开始编辑recordS
  5. 用户1保存记录
  6. 用户2保存记录
  7. 抛出 org.hibernate.StaleObjectStateException(见下文)

我读到这是由于数据库中更新的版本号与该特定实体当前内存中的版本号之间的差异引起的。但是,当我尝试使用查询或使用 EntityManager.find() 方法在数据库中查找当前版本号以从数据库获取最新信息时,我发现版本号没有任何差异。我还尝试手动合并旧实体和新实体之间的更改并使用entityManager.merge(object) 方法,但没有成功。关于如何解决这个问题有什么想法吗?

13290 [http-8080-7] ERROR org.hibernate.event.def.AbstractFlushingEventListener  - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [edu.pitt.nmrl.med.domain.medical.MedicalHistory#362]
    at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1934)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2578)
    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2478)
    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2805)
    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:114)
    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:268)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:260)
    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:180)
    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:64)
    at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1175)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1251)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:241)
    at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getResultList(CriteriaQueryCompiler.java:260)
    at edu.pitt.nmrl.med.services.SurveyService.checkMedicalDup(SurveyService.java:613)
    at edu.pitt.nmrl.med.services.SurveyService.save(SurveyService.java:790)
    at edu.pitt.nmrl.med.services.SurveyService$$FastClassByCGLIB$$b6424505.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
    at edu.pitt.nmrl.med.services.SurveyService$$EnhancerByCGLIB$$5831613c.save(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
    at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:273)
    at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
    at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
    at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
    at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:387)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
    at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
    at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
    at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:31)
    at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
    at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
    at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
    at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:26)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
    at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
Jan 23, 2012 12:07:16 PM com.sun.faces.application.ActionListenerImpl processAction
SEVERE: javax.persistence.OptimisticLockException
javax.faces.el.EvaluationException: javax.persistence.OptimisticLockException
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UICommand.java:387)
    at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
    at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:18)
    at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
    at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
    at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:31)
    at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
    at com.icesoft.faces.webapp.http.servlet.BasicAdaptingServlet.service(BasicAdaptingServlet.java:16)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
    at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:53)
    at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:26)
    at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
    at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:131)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:188)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:619)
Caused by: javax.persistence.OptimisticLockException
    at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1261)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1187)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1168)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:250)
    at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getResultList(CriteriaQueryCompiler.java:260)
    at edu.pitt.nmrl.med.services.SurveyService.checkMedicalDup(SurveyService.java:613)
    at edu.pitt.nmrl.med.services.SurveyService.save(SurveyService.java:790)
    at edu.pitt.nmrl.med.services.SurveyService$$FastClassByCGLIB$$b6424505.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
    at 

以下是乐观锁的工作原理:

  1. User1开始编辑recordS - recordA从数据库加载版本V
  2. User2开始编辑recordS - recordA从数据库加载版本V- 与上面完全相同
  3. 用户1保存记录 - recordA已保存,但 Hibernate 透明地添加:

    UPDATE
    ...
    SET V = V + 1
    WHERE version = V
    

    此时Hibernate会验证从数据库返回的修改记录条数是否准确1。如果查询修改了0条记录则意味着WHERE version = V条款没有得到满足。在这种情况下,一切顺利,版本设置为V + 1(重要的!)

  4. 用户2保存记录- Hibernate 做完全相同的事情,仍然保留旧的V内存中的版本号。不幸的是在这种情况下WHERE version = V不满足条件,因为版本现在是V + 1。该查询返回 0 个修改记录,这使得 Hibernate 相信(正确地)该记录同时被修改。这就是例外所说的。

所以你对此能做些什么?只需捕获异常并:

  1. 重复整个事务,但重新加载实体(使用新版本V + 1)这样更新后您就不会丢失最后的更改

  2. 或者通知用户该对象同时被修改,以便她可以检查新版本。

这两种解决方案都可以,具体取决于您的用例。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

并发更新期间的 Hibernate StaleObjectStateException 的相关文章

随机推荐

  • Android 后台服务在滑出时崩溃

    当我从任务管理器中删除我的应用程序时 剩下 0 个进程和 1 个服务 应用程序一次又一次崩溃 我应该做什么来解决它 这是我的服务等级 我还想问一件事OnStart 方法和OnStartCommand 方法之间的区别 package com
  • 在 JavaScript“窗口”对象中存储变量是使用该对象的正确方法吗?

    也许 我刚刚解决了我的问题 从对话框窗口成功提交表单后如何更新前端内容 通过在 JavaScript 中 存储 保存 变量window目的 然而 由于我是 JavaScript 方面的新手 我对是否在 JavaScript 中存储 保存变量
  • mysql 如果存在

    我已经盯着这个看了有一段时间了 也许一些新的眼睛能够指出我做错了什么 这是我的查询 IF EXISTS SELECT FROM admin rule module WHERE rule set id 13 AND entity id 2 b
  • 使用应用程序访问令牌时,Android 中的 OAUTH 访问令牌无效

    正如标题所示 当我尝试请求获取安装了该字段的好友列表时 me friends Fields installed access token 我的 logcat 中出现以下错误 Invalid OAuth access token 当查看 fa
  • SSIS包通过部署升级

    在我们的 QA 虚拟环境中 其中包含多个 SQL Server 我想部署一个通过 Visual Studio 2010 维护的 SSIS 2012 包 ispac 项目部署 目标 SSIS 服务器是 2012 但工作站上的客户端包括 SQL
  • php 邮件重复

    有什么原因会导致重复发送电子邮件吗 我有一个 PHP 页面 上面只有这段代码 每次运行它时 它都会向我发送两封电子邮件 感谢您的意见 事实证明这是一个浏览器插件问题 特别是 Firefox 4 0 1 上的 ySlow 2 1 0 我要求我
  • 在 FileZilla 中下载文件的命令行选项

    我正在使用 FileZilla GUI 从 FTP 服务器下载文件 谁能告诉我一个从 FTP 服务器下载文件到本地文件系统的命令行参数 FileZilla 没有任何允许自动传输的命令行参数 也没有任何其他方式 See FileZilla 客
  • 如何在 Google Maps API V3 中检索英文结果

    directionsDisplay new google maps DirectionsRenderer directionsDisplay setMap map directionsService new google maps Dire
  • 对 pandas 数据集执行 SQL 查询

    我有一个 pandas 数据集 称为 df 我怎样才能做类似下面的事情 df query select from df 谢谢 对于那些了解 R 的人 有一个名为 sqldf 的库 您可以在 R 中执行 SQL 代码 我的问题基本上是 pyt
  • 获取不带查询字符串的 url

    我有一个像这样的网址 http www example com mypage aspx myvalue1 hello myvalue2 goodbye 我想要得到http www example com mypage aspx从中 你能告诉
  • JQuery load() 和 .prepend()

    好的 我有以下代码 function ul postbit load load php fadeIn slow 3000 我想要实现的是加载 load php 之后将结果添加到 li 并让它淡入 此时它会覆盖其中的内容ul postbit
  • 未经身份验证的使用超出了 Google Api 日历的每日限制

    我正在测试示例代码 它一直有效 但突然我得到 error errors domain usageLimits reason dailyLimitExceededUnreg message Daily Limit for Unauthenti
  • Windows 不会从所有接口接收多播 IPv6 数据包

    我正在尝试使用此 python 2 7 代码在 Windows 上接收 IPv6 多播数据包 发送到 ff02 1 地址 import socket import win inet pton import struct socket IPP
  • 在java中添加一个简单的按钮,但java不允许我这样做

    好吧 从我的角度来看 我的代码相当不错 足以获得及格分数 但我在添加简单的刷新 随机播放按钮时遇到了麻烦 不使用 JOptionPane 的帮助 Eclipse 似乎没有意识到我创建了一个按钮 这对我来说根本没有意义 因为它告诉我一些关于节
  • python 中的猴子修补:什么时候我们需要它?

    在 Python 中 术语monkey patch仅指在运行时动态修改类或模块 作为初学者 我很难在 python 上下文中理解这个术语 有人能用一个现实世界的例子向我解释一下我们到底是怎么做的吗 类的动态修改 运行时动态修改模块 我坚持用
  • 查找下一个最接近的日期

    我有一些日期当前存储为字符串列表 例如 List
  • 将资源绑定到自定义控件属性

    我正在创建一个自定义按钮 通常显示稍微褪色的文本 并在MouseOver or MouseDown 我在中定义了两个资源Generic xaml我的控件来表示这些文本颜色的画笔
  • edu.stanford.nlp.io.RuntimeIOException:无法连接到服务器

    我正在尝试使用 CoreNLP 服务器注释多个句子 但是 如果我尝试这样做too many我得到的句子 Exception in thread Thread 48 edu stanford nlp io RuntimeIOException
  • Android 片段无法正确替换

    我正在尝试使用片段构建 3 0 的应用程序 应用程序的左侧有一个静态片段 右侧有一个动态片段 我的动态部分中的每个片段都有一个标题 每当我去替换初始片段时 第一个片段的标题仍然显示在第一个片段的标题上方 连续的替换替换了下部 但仍然显示初始
  • 并发更新期间的 Hibernate StaleObjectStateException

    我在 Java J2EE Web 应用程序中使用 Hibernate 3 5 2 和 Spring Core 3 0 1 当不同的用户同时更新同一记录时 我收到 StaleObjectStateExcpetion 事务由 javax per