javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: не удалось выполнить инструкцию - PullRequest
0 голосов
/ 28 мая 2020

Я получаю ошибки ниже. Кто-нибудь может мне в этом помочь? Я запускаю обновления в 3 разных потоках. в основном это не та же запись. но все же вижу эту ошибку. Когда я делаю то же самое с 1 потоком, я не вижу этой ошибки

SRK_GENERAL_002 org.hibernate.exception.LockAcquisitionException: не удалось выполнить оператор org.mule.component.ComponentException: javax.persistence.PersistenceException: org. hibernate.exception.LockAcquisitionException: не удалось выполнить инструкцию. Компонент, вызвавший исключение: DefaultJavaComponent {updatejourney.update_db.component.1769321531}. javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: не удалось выполнить инструкцию. Компонент, вызвавший исключение: DefaultJavaComponent {updatejourney.update_db.component.1769321531}. javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: не удалось выполнить оператор org.mule.component.ComponentException: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: не удалось выполнить оператор. Компонент, вызвавший исключение: DefaultJavaComponent {updatejourney.update_db.component.1769321531}. в org.mule.component.DefaultComponentLifecycleAdapter.invoke (DefaultComponentLifecycleAdapter. java: 355) в org.mule.component.AbstractJavaComponent.invokeComponentInstance (AbstractJavaComponent. java: 82) в org.muleJavaComponent. . java: 73)

====

Вызвано: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: не удалось выполнить оператор в org.hibernate.jpa .spi.AbstractEntityManagerImpl.convert (AbstractEntityManagerImpl. java: 1692) в org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert (AbstractEntityManagerImpl. java: 1602) в org.hibernateManagerImpl. . java: 1700) на org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate (AbstractQueryImpl. java: 70) на com.srk.esb.orm.update.builder.UpdateJourney.createJourneyRoutePoints (UpdateJourney. * : 3224)

=====

Вызвано: org.hiber nate.exception.LockAcquisitionException: не удалось выполнить оператор в org.hibernate.exception.internal.SQLStateConversionDelegate.convert (SQLStateConversionDelegate. java: 123) в org.hibernate.exception.internal.StandardSQLExceptionConverter.convert27 (* StandardSQLExceptionConverter.convert27 (* StandardSQLExceptionConverter.convert27 (* StandardSQLExceptionConverter.convert27) 42) в org.hibernate.engine.jdb c .spi.SqlExceptionHelper.convert (SqlExceptionHelper. java: 111) в org.hibernate.engine.jdb c .spi.SqlExceptionHelper.convert (SqlExceptionHelper. java: 97) в org.hibernate.engine.jdb c .internal.ResultSetReturnImpl.executeUpdate (ResultSetReturnImpl. java: 207) в org.hibernate.hql.internal.ast.exe c .BasicExecututeor.doExec BasicExecutor. java: 91) в org.hibernate.hql.internal.ast.exe c .BasicExecutor.execute (BasicExecutor. java: 60) в org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate (QueryTranslatorImpl. java: 429) в org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate (HQLQueryPlan. java: 374) в org.hibernate.internal.Ses sionImpl.executeUpdate (SessionImpl. java: 1361) в org.hibernate.internal.QueryImpl.executeUpdate (QueryImpl. java: 102) в org.hibernate.jpa.internal.QueryImpl.internalExecuteUpdate (* 10Impl 405) в org.hibernate.jpa.spi.AbstractQueryImpl.executeUpdate (AbstractQueryImpl. java: 61) ... еще 79 Причина: com.microsoft.sqlserver.jdb c .SQLServerException: Transaction (Process ID 64) был заблокирован на ресурсах блокировки с другим процессом и был выбран в качестве жертвы взаимоблокировки. Повторите транзакцию. на com.microsoft.sqlserver. jdb c .SQLServerException.makeFromDatabaseError (SQLServerException. java: 216) в com.microsoft.sqlserver.jdb c .SQLServerStatement.getNextResult (SQLServerStatement. java: 1515) в com.microsoft 1049 * .SQLServerPreparedStatement.doExecutePreparedStatement (SQLServerPreparedSt

=====

Ниже мой код

private void createJourneyBS(Journey journey, JourneyRoute journeyRouteOld, RouteType routeType, Integer version) {

    List<RoutePointType> routePointTypes = routeType.getRoutePoint();

    for (RoutePointType routePointType : routePointTypes) {

        JourneyBSBuilder builderivs = builderHelper.getJourneyBSBuilder(routePointType);
        JourneyBS KRTT = builderivs.build();
        List<JourneyRouteTime> timeList = getJourneyRouteTime(journey, journeyRouteOld, routePointType);

        Query query = entityManager.createQuery("UPDATE JourneyBS jrp SET "
        + "jrp.type  = :type, "
        + "jrp.lastUpdatedTime = :lastUpdatedTime, "
        + "jrp.hasEnteringTime = :hasEnteringTime, "
        + "jrp.islock = :islock, "
        + "jrp.isAcsPoint = :isAcsPoint, "
        + "jrp.description = :description, "
        + "jrp.version = :version "
        + "Where jrp.journey.journeyId = :journeyId and jrp.rPN = :rPN and jrp.sequenceNr = :sequenceNr");


        query.setParameter("type",  KRTT.getType());
        query.setParameter("lastUpdatedTime",  KRTT.getLastUpdatedTime());

        query.setParameter("hasEnteringTime", KRTT.getHasEnteringTime());
        query.setParameter("islock",  KRTT.getIslock());

        query.setParameter("isAcsPoint",  KRTT.getIsAcsPoint());
        query.setParameter("description", KRTT.getDescription());
        query.setParameter("version", version);

        query.setParameter("journeyId", journey.getJourneyId());

        query.setParameter("rPN",  KRTT.getrPN());
        query.setParameter("sequenceNr", KRTT.getSequenceNr());

        int res = query.executeUpdate();

        if(res == 1){

            updateTimeList(timeList, KRTT, journey, version);
        }

        if(res == 0){

            KRTT.setJourneyRoute(journeyRouteOld);
            KRTT.setJourney(journey);
            KRTT.setVersion(version);

            genericDAO.persist(KRTT);
            createJourneyRouteTime(journey, KRTT,  routePointType, version);
        }


    }
}
...