zoukankan      html  css  js  c++  java
  • hibernate 异常处理

    公司跑项目时,遇到过非常诡异的报错,信息如下:
    org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [select count(*) from User u where u.userName=? and u.userPassword=? ]

    Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped

    出现这中错误情况有两种:

    1,配置文件没有加载到hibernate的实体列表里面

    2,映射文件的字段与数据库字段不一致,或者名称不一致导致

    就只有这两种情况

    最后我发现还是实体类的配置没配好,是这么解决的:
    Entity实体类抬头设置了@Entity(name="xxx") 想要改表的名字不是设置Entity注解的name属性,而是设置Table注解的name属性,更改效果如下:要这么写 @Entity @Table(name="xxx"); 这样就好了。



  • 相关阅读:
    玩游戏(dfs)
    Find them, Catch them(并查集)
    Shredding Company(dfs)
    Sudoku(dfs)
    Network Saboteur(dfs)
    棋盘问题(dfs)
    Curling 2.0(dfs)
    A Knight's Journey(dfs)
    15. 3Sum
    12. Integer to Roman
  • 原文地址:https://www.cnblogs.com/hangaozu/p/5379699.html
Copyright © 2011-2022 走看看