【发布时间】:2018-06-23 16:37:29
【问题描述】:
我在 Spring Boot 和 PostgreSql 中有一个实体,我正在使用 @Column 注释映射到数据库。这是我的实体片段代码:
@Entity(name = "users")
@Table(name = "users", schema = "public")
public class User implements Serializable {
/**
*
*/
private static final long serialVersionUID = 12355345L;
@Id
@Column(name = "user_id")
private String userid;
@Column(name = "user_name")
private Integer username;
当 id 使用邮递员运行和测试时,我得到一个错误:
org.springframework.dao.InvalidDataAccessResourceUsageException: 可以 不提取结果集; SQL [不适用];嵌套异常是 org.hibernate.exception.SQLGrammarException:无法提取 结果集
Caused by: org.postgresql.util.PSQLException: ERROR: column users0_.usersid does not exist Hint: Perhaps you meant to reference the column "users0_.user_id".
我不知道为什么。如何解决?
【问题讨论】:
-
@Table(name = "users", schema = "public")in this line isusersyour table?意思是名字对吗?并且无需在@entity中添加名称 -
向我们展示查询。
标签: postgresql hibernate spring-boot