在Spring Data JPA中进行参数化查询以创建一个抛出丢失的用户或角色名称异常的用户

问题描述 投票:0回答:1

我正在尝试通过使用本机查询的spring data jpa在Oracle数据库中创建用户,但失败,并出现错误:缺少用户或角色名称异常

@Query(value="create user :userName identified by \"Qwert123!\"",nativeQuery=true)
void createUser(@Param("userName")String userName);

我偶然发现了类似的问题:Parameterized queries to create a user throwing missing user or role name exception

如何使参数化查询在我的情况下起作用?

hibernate spring-boot spring-data-jpa
1个回答
0
投票
您需要在该方法上添加@Modifying注释。
© www.soinside.com 2019 - 2024. All rights reserved.