search

Home  >  Q&A  >  body text

java - Can the input parameters of Spring Data Jpa update operation be passed in as objects?

For example, the following code

    @Query("update BbsPost b set b.content = ?2,b.updateTime = current_timestamp where b.id = ?1")
    @Modifying
    void updatePostContent(Integer id, String content);

The id and content are attributes of the object Book. Can I define the input parameter as Book, just like

void updatePostContent(Book book);

If possible, how to write my update sql?

漂亮男人漂亮男人2747 days ago730

reply all(1)I'll reply

  • 漂亮男人

    漂亮男人2017-05-17 10:06:29

    Currently modification operations are not possible, only queries can use SPEL expressions.
    Official example: https://spring.io/blog/2014/0...

    reply
    0
  • Cancelreply