当前位置: 首页 > 知识库问答 >
问题:

组织。冬眠StaleStateException:批处理更新从更新[0]返回了意外的行计数;实际行数:0;预期

伯和蔼
2023-03-14

当我试图从spring mvc应用程序更新数据库中的值时,我遇到了以下错误:

 org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
        at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
        at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
        at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at com.sun.proxy.$Proxy21.updatePerson(Unknown Source)
        at se.lowdin.civilforsvaret.webapp.controller.EditPersonContoller.save(EditPersonContoller.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
    DEBUG: org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    TRACE: org.hibernate.jdbc.AbstractBatcher - closing statement
    ERROR: org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
        at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
        at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
        at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at com.sun.proxy.$Proxy21.updatePerson(Unknown Source)
        at se.lowdin.civilforsvaret.webapp.controller.EditPersonContoller.save(EditPersonContoller.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)
    TRACE: org.hibernate.jdbc.ConnectionManager - registering flush end
    DEBUG: org.hibernate.transaction.JDBCTransaction - rollback
    DEBUG: org.hibernate.transaction.JDBCTransaction - re-enabling autocommit
    DEBUG: org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection
    TRACE: org.hibernate.jdbc.JDBCContext - after transaction completion
    DEBUG: org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    TRACE: org.hibernate.impl.SessionImpl - after transaction completion
    TRACE: org.hibernate.impl.SessionImpl - closing session
    TRACE: org.hibernate.jdbc.ConnectionManager - performing cleanup
    DEBUG: org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    TRACE: org.hibernate.jdbc.JDBCContext - after transaction completion
    DEBUG: org.hibernate.jdbc.ConnectionManager - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    TRACE: org.hibernate.impl.SessionImpl - after transaction completion
    feb 07, 2014 11:04:32 FM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet [spring] in context with path [/CRUDWebAppMavenized] threw exception [Request processing failed; nested exception is org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1] with root cause
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
        at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
        at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
        at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
        at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
        at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
        at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
        at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
        at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
        at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
        at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
        at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:393)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:120)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at com.sun.proxy.$Proxy21.updatePerson(Unknown Source)
        at se.lowdin.civilforsvaret.webapp.controller.EditPersonContoller.save(EditPersonContoller.java:57)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
        at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:722)

所以我的实际错误似乎是数据库中的ID和正在更新的内容。在我的GET方法中,我得到的是当前ID,在本例中是10。

@Autowired
PersonService service;


@RequestMapping(method = RequestMethod.GET)
public ModelAndView index(@PathVariable int id) {

    EditPersonBean bean = new EditPersonBean();

    if (id > 0) {
        Person person = service.getPerson(id);
        bean.copyValuesToBean(person);
    }

    ModelAndView mav = new ModelAndView("editPerson");
    mav.addObject("editPersonBean", bean);
    return mav;

}

但在我的post方法中,这个ID是10,突然变成了0,我相信这可能是这个错误的原因?

@RequestMapping(value = "/edit", method = RequestMethod.POST)
        public String save (EditPersonBean bean, Person person, @RequestParam(value = "file", required = false) MultipartFile file) {


            System.out.println("incoming id : " + bean.getId());

            try {

                Blob blob = Hibernate.createBlob(file.getInputStream());
                bean.copyBeanValuesToPerson(person,blob);
                service.updatePerson(person);

            } catch (IOException e) {
                e.printStackTrace();
            }


            return "redirect:/person.html";
        }

那么,这可能是什么原因,还是错误是别的什么?

public class EditPersonBean {

        private int id;
        private String firstName;
        private String lastName;
        private String email;
        private String phoneNumber;
        private String otherInfo;
        private Blob image;
        private String userName;
        private String password;

        public void copyValuesToBean(Person person){

            setId((int) person.getId());
            setFirstName(person.getFirstName());
            setLastName(person.getLastName());
            setEmail(person.getEmail());
            setPhoneNumber(person.getPhoneNumber());
            setOtherInfo(person.getOtherInfo());
            setImage(person.getImage());
            setUserName(person.getUserName());
            setPassword(person.getPassword());;

        }

@Entity
public class Person {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    private int id;
    @Column(name = "FIRSTNAME")
    private String firstName;
    @Column(name = "SECONDNAME")
    private String lastName;
    @Column(name = "EMAIL")
    private String email;
    @Column(name = "MobilePHONENUM")
    private String phoneNumber;
    @Column(name = "OTHER")
    private String otherInfo;
    @Column(name = "image")
    @Lob
    private Blob image;
    @NotEmpty
    @Size(min = 1, max = 50)
    @Column(name = "username")
    private String userName;
    @NotEmpty
    @Size(min = 1, max = 20)
    @Column(name = "password")
    private String password;

    public Person() {

    }

    public Person(int id, String firstName, String lastName, String email,
            String phoneNumber, String otherInfo, Blob image, String userName, String password) {

        setId(id);
        setFirstName(firstName);
        setLastName(lastName);
        setEmail(email);
        setPhoneNumber(phoneNumber);
        setOtherInfo(otherInfo);
        setImage(image);
        setUserName(password);
        setPassword(userName);

    } //Getters and setters...

JPA课程:

@Override
    public Person getPerson(int personId) {
        return (Person)session.getCurrentSession().get(Person.class, personId);
    }

共有3个答案

游安康
2023-03-14

在我的Spring boot应用程序中,我也面临着这个问题。我的案例如下:用@Transaction注释的Outter方法。在这里面,我有两种不同的方法:方法1是删除记录,它也有@Transaction。方法2读取相同的记录,也用@Transaction注释。这里出现问题是因为默认情况下@Transaction注解支持传播。使用当前事务的必填项。因此,在方法2中,当我尝试读取数据时,它显然会出现陈旧异常。对我有效的修复方法是我用@Transactional(propagation=propagation.REQUIRES_NEW)注释方法1

所以方法2总是使用一个单独的事务,它不会有过时的数据。

花品
2023-03-14

要确切知道发生了什么,唯一的方法是在Hibernate中打开Hibernate语句日志记录。cfg。xml配置。这是因为堆栈跟踪中的行号都与执行实际Hibernate操作的代码部分不对应。相反,这些操作是批处理的,然后在事务关闭时(或在批处理了指定数量的操作之后)一次性执行。

若要启用Hibernate语句日志记录,

    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="use_sql_comments">true</property>

也就是说,上次我遇到这个问题时,是一个记录被另一个线程/事务中的general HQL update删除的情况,然后当前线程/事务试图按ID删除完全相同的记录。不幸的是,由于事务是成批处理的,所以在执行删除操作时,您没有看到它,但是,在程序执行之后的某个时间点。因此,需要打开语句日志来查看哪个实际的Hibernate操作触发了异常。

颜嘉福
2023-03-14

当hibernate无法找到需要更新的所有行时,通常会导致此错误。这意味着,当你试图更新从数据库中提取的一些对象时,它们实际上已经不存在了(或者根本不存在)。

这可能是因为另一个线程正在删除它们,或者DB的隔离模式设置为read_Uncommitted,因此由另一个事务创建的行无法保存(由于事务失败),不再存在。

 类似资料:
  • 当现有用户发出请求时,该方法首先删除最旧的记录,然后再保存新请求。如果请求传入的速度不太快(使用Oracle数据库),下面的代码可以正常工作。 输出: 但是,如果用户以非常快速的方式提交请求,即happy clicker,则相同的代码会生成StaleStateException错误。 似乎在下一条记录出现之前,代码还没有时间完成更改,导致代码尝试删除同一条记录两次。除了在这种方法之前改变前端或其他

  • 我不明白为什么我会犯这样的错误,我的头撞在墙上已经好几个小时了。 当试图删除数据库中我没有使用Hibernate添加的任何行(即通过常规SQL输入的数据库的所有现有行)时,上面的代码给了我一个错误。 如果我在应用程序中使用Hibernate插入一行,那么就可以完全删除该行。 我不能理解的是,我先从数据库中获取一个用户,这样我就知道这个用户存在。 我已经检查了Hibernate SQL,在运行sel

  • 我和冬眠有麻烦了。 我有个例外 我试图显示数据库中的日期,我的一列是char,在我的类中有一个 ' 我创建了一个来进行转换 `公共类FilialStatusType扩展了TypeHibernate{public static final String TYPE=“FilialStatusType”; ### 有人能帮我吗?

  • 问题内容: 我收到以下hibernate错误。我能够确定导致问题的功能。不幸的是,函数中有多个数据库调用。由于hibernate在事务结束时刷新会话,因此我找不到导致问题的行。下面提到的hibernate错误看起来像是一般错误。甚至都没有提到哪个Bean导致了问题。有人熟悉这个hibernate错误吗? 问题答案: 没有交易的代码和映射,几乎不可能调查问题。 但是,要更好地了解导致问题的原因,请尝

  • 当我试图保存预订到DB,我得到了。在我的情况下,我有一个预订实体,预订号是主键,而不是自动增量。所以我的逻辑是: > 生成预订号并将其设置为预订。 调用。 顺便说一下,我正在使用hibernate3 spring MySql5。5并在tomcat6中运行,有关更多详细信息,请参阅我的编码和日志: 预订实体 预订DAO保存功能 当我的struts2操作调用save函数来保存预订时,它将得到以下错误

  • 问题内容: 我在下面编写了此方法,该方法假定是从数据库中删除成员记录。但是,当我在servlet中使用它时,它将返回错误。 会员班 控制器部分 HTTP状态500 有时,当我尝试多次执行页面时,甚至会引发此错误。 有人知道究竟是什么引起这些错误吗? 问题答案: 该错误可能是由多种原因引起的。我不为此而功劳,在这里找到了它。 在提交对象之前刷新数据可能会导致清除所有等待持久化的对象。 如果对象具有自