And*_*310 9 spring annotations intellij-idea spring-data-jpa
我正在创建一个实现JpaRepository的UserRepository,并与User实体一起使用.我需要一种方法来更新用户名.我决定在@Query的帮助下完成它.但它的标志是Intellij.这是我的存储库代码:
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
@Modifying
@Query(value = "update User user set user.name= %?username"))
void updatingUser(@Param(value = "username") String username);
}
Run Code Online (Sandbox Code Playgroud)
对于实体:
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "user_id")
private Long id;
@NotNull
@Column(name = "user_name")
private String username;
}
Run Code Online (Sandbox Code Playgroud)
我遇到了这样一个问题:"这里不允许注释"Intellij Idea说道并用@Query注释标记了这一行.这让我感到困惑
对不起大家.对于我来说,在这一行的末尾写双引号真是太愚蠢了.但我实际上不明白为什么Intellij没有注意到这一点,但开始用另一个错误标记这一行
| 归档时间: |
|
| 查看次数: |
21196 次 |
| 最近记录: |