gpt4 book ai didi

java - MYSQL Hibernate 5.2 createStoredProcedureQuery

转载 作者:行者123 更新时间:2023-11-29 19:37:59 24 4
gpt4 key购买 nike

这是我调用 mysql 存储过程的代码

StoredProcedureQuery query = getCurrentSession().createStoredProcedureQuery("updateinselgibilitycount")
.registerStoredProcedureParameter("ppatientinsid", Long.class, ParameterMode.IN)
.registerStoredProcedureParameter("pencounterID", Long.class, ParameterMode.IN)
.setParameter("ppatientinsid", ppatientinsid).setParameter("pencounterID", encounterID);
query.execute();

我收到以下错误

    10:04:42.167 [http-nio-8080-exec-3] WARN  o.h.p.internal.ProcedureCallImpl - HHH000456: Named parameters are used for a callable statement, but database metadata indicates named parameters are not supported.
Hibernate:
{call updateinselgibilitycount(?,?)}
10:04:42.329 [http-nio-8080-exec-3] ERROR c.p.w.utilities.ExceptionHandler - User ID : 1
Error : org.springframework.dao.InvalidDataAccessApiUsageException: Executing an update/delete query; nested exception is javax.persistence.TransactionRequiredException: Executing an update/delete query
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:413)
at org.springframework.orm.hibernate5.HibernateExceptionTranslator.translateExceptionIfPossible(HibernateExceptionTranslator.java:54)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)

最佳答案

您需要一个事务来执行存储过程。使用 @Transactional 注释您的方法

关于java - MYSQL Hibernate 5.2 createStoredProcedureQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41477423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com