读好书,交益友
分类: Java
2015-04-16 17:52:38
@Modifying @Query("update User u set u.firstname = ?1 where u.lastname = ?2") int setFixedFirstnameFor(String firstname, String lastname);首先让人奇怪的是,repository method只能返回int或者转为void,因为这个操作只会把数据写入到数据库,但是不会select。
@Modifying(clearAutomatically = true) @Query("update RssFeedEntry feedEntry set feedEntry.read =:isRead where feedEntry.id =:entryId") void markEntryAsRead(@Param("entryId") Long rssFeedEntryId, @Param("isRead") boolean isRead);