gpt4 book ai didi

java - 如何使用带有无效返回参数的 JPA 2.1 @NamedStoredProcedureQueries?

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:47:39 28 4
gpt4 key购买 nike

给定以下带注释的命名存储过程查询:

@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(
name = "procedureName",
procedureName = "stored_procedure"
)
})

然后执行:

StoredProcedureQuery query = entityManager.createNamedStoredProcedureQuery("procedureName");
query.executeUpdate();

存储过程返回 postgres void

导致异常:原因:org.hibernate.MappingException:没有 JDBC 类型的方言映射:1111

如何解决?

最佳答案

我使用一些辅助代码解决了这个问题。

@SqlResultSetMapping(
name = "VOID_MAPPING",
classes = {
@ConstructorResult(targetClass = VoidClass.class, columns = {})
}
)

将 resultSetMappings 添加到 @NamedStoredProcedureQuery

 resultSetMappings = {
"VOID_MAPPING"
}

VoidClass 只是一个空类。

public class VoidClass {}

但是,我希望有更好的解决方案。

关于java - 如何使用带有无效返回参数的 JPA 2.1 @NamedStoredProcedureQueries?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24427798/

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