简体   繁体   English

PSQLException:错误:列不存在

[英]PSQLException: ERROR: column does not exist

I have following entities:我有以下实体:

@Entity
@Getter
@Setter
@Table(name = "nomenclature", schema = "public")
public class Nomenclature implements Serializable {
    @Id
    @Column(name = "id")
    private Long id;

    @Column(name = "name")
    private String name;

    @OneToMany
    @JoinTable(name="nomenclature_versions",
            joinColumns= @JoinColumn(name="nomenclature_id", referencedColumnName="id"))
    private List<NomenclatureVersion> version;
}

and

@Entity
@Setter
@Getter
@Table(name = "nomenclature_versions", schema = "public")
@NoArgsConstructor
public class NomenclatureVersion implements Serializable {
    @Id
    @Generated(GenerationTime.INSERT)
    @Column(name = "id")
    private Long id;
    @Column(name = "nomenclature_id")
    private Long nomenclatureId;
    @Column(name = "user_id")
    private Long userId;
    @Column(name = "creation_date")
    private LocalDateTime creationDate;
    @Column(name = "puls_code")
    private String pulsCode;
    @Column(name = "pic_url")
    private String picUrl;
    @Column(name = "current")
    private boolean current;
}

When im trying to get Nomenclature with JPARepository getById(id) method im getting org.postgresql.util.PSQLException: ERROR: column version0_.version_id does not exist当我尝试使用 JPARepository getById(id) 方法获取命名法时,我正在获取org.postgresql.util.PSQLException: ERROR: column version0_.version_id does not exist

It feels like the problem is around Hibernate Naming Strategies but i cant solve it.感觉问题出在 Hibernate 命名策略附近,但我无法解决。

Is there any other way to let Hibernate know which column should it use to join tables?有没有其他方法可以让 Hibernate 知道它应该使用哪一列来连接表?

Don't use @JoinTable , the table is the same as the entity you are referencing.不要使用@JoinTable ,该表与您引用的实体相同。 You just have to specify the @JoinColumn , hibernate will look for the column in the table referenced by the entity you are mapping the list to, NomenclatureVersion :您只需指定@JoinColumn , hibernate 将在表中查找您将列表映射到的实体所引用的列NomenclatureVersion

@OneToMany
@JoinColumn(name="nomenclature_id") 
private List<NomenclatureVersion> version;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PSQLException:错误:列不存在位置:8 - PSQLException: ERROR: column does not exist Position: 8 Hibernate:PSQLException:错误:列“column_name”不存在 - Hibernate: PSQLException: Error: Column “column_name” does not exist PSQLException:错误:关系“文件夹”不存在 - PSQLException: ERROR: relation “folder” does not exist PSQLException:错误:运算符不存在:bigint = text[] - PSQLException: ERROR: operator does not exist: bigint = text[] org.postgresql.util.PSQLException:错误:列 column0_.pk 不存在 Position:8 - org.postgresql.util.PSQLException: ERROR: column column0_.pk does not exist Position: 8 错误:org.postgresql.util.PSQLException:错误:列 userinfo0_.dtype 不存在 - ERROR:org.postgresql.util.PSQLException:ERROR: column userinfo0_.dtype does not exist util.PSQLException:错误:列不存在(LEFT JOIN 和@Formula 的问题) - util.PSQLException: ERROR: column does not exist (problems with LEFT JOIN and @Formula) org.postgresql.util.PSQLException:错误:列“id”不存在 - Java Web 服务 - org.postgresql.util.PSQLException: ERROR: column "id" does not exist - Java Web Service org.postgresql.util.PSQLException:错误:列 systementi0_.id 不存在 - Hibernate、PostgreSql - org.postgresql.util.PSQLException: Error: column systementi0_.id does not exist - Hibernate, PostgreSql org.postgresql.util.PSQLException:错误:列 user0_.id 不存在 - Hibernate - org.postgresql.util.PSQLException: ERROR: column user0_.id does not exist - Hibernate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM