org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped报错解决
程序员文章站
2022-04-13 14:09:26
...
例子:sprintboot环境中
public interface UserRepository extends CrudRepository<User,Long> {
@Modifying
@Query("update User set password=:psd where id=:id")
void updatePassword(@Param("id") Long id, @Param("psd") String password);
}
原因:
1. 表或字段没有映射。
解决:
- 在实际操作的类上(例子中是User),只写@Entity不行,要在下方添加映射表@Table(name = "tb_user")。
- 语句中出现的查询字段,在类中也都要出现。
2. HQL语句写法错误。
解决:注意语句里的User不能写成user或tb_user,名字必须为java类的类名。同理,字段也一样。
推荐阅读
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
解决小米手机USB安装apk时AS报错:INSTALL_FAILED_USER_RESTRICTED
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法
-
【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user
-
解决报错:Mapped Statements collection already contains value for...
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法
-
mysql 1449:The user specified as a definer ('root'@'%') does not exist 报错解决方法
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决
-
Linux连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)的解决