0

I'm using Spring Boot and I'm trying to make a function that updates an attribute using a native query.

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.

I have browsed through a bunch of similar topics on here with no solution.

1
  • It seems like you're not getting an error, but I wouldn't have expected this to work with the extra space in : selected_id. Commented Jan 23, 2020 at 3:34

1 Answer 1

1
@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);
Sign up to request clarification or add additional context in comments.

1 Comment

I just had to change that updating function to void.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.