简体   繁体   English

Spring Boot JPA @Query 更新不起作用

[英]Spring Boot JPA @Query Update does not work

I'm using Springboot and I'm trying to make a function that updates an attribute using native query我正在使用 Springboot 并且我正在尝试创建一个使用本机查询更新属性的函数

this is a part of my interface:这是我的界面的一部分:

@Modifying(clearAutomatically = true, flushAutomatically = true) // mandatory if native quaries are modying something in the dataBase
@Transactional
@Query("""
    update pojazd 
    set czy_zarchiwizowany = true 
    where id =: selected_id""", nativeQuery = true) 
fun archwizujPojazd(@Param("selected_id") selected_id:Long):Boolean

The function works.该功能有效。 It returns true, but it has no effect on the dataBase它返回true,但它对数据库没有影响

Any help?有什么帮助吗?

I have browsed through a bunch of similar topics on here with no solution.我在这里浏览了一堆类似的主题,但没有解决方案。

I would be very glad for your help.我会很高兴得到你的帮助。

Please add the class details of "pojazd".请添加“pojazd”的类详细信息。 There may be a chance of miss matching the name "id".可能会错过匹配名称“id”的机会。 It will be helpful, if you go through this blog Spring Data JPA @Modifying Annotation .如果您阅读此博客Spring Data JPA @Modifying Annotation ,这将很有帮助。

@Modifying(clearAutomatically = true, flushAutomatically = true) 
@Transactional
@Query(value = "update pojazd  set czy_zarchiwizowany = true 
    where id = :selected_id", nativeQuery = true) 
fun archwizujPojazd(@Param(value="selected_id") Long selected_id);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM