简体   繁体   English

org.hibernate.MappingException:属性映射的列数错误

[英]org.hibernate.MappingException: property mapping has wrong number of columns

I practice whit spring framework and database (PostgreSQL) and I got the tables whit IntelliJ ( Modules JPA ), and I have this exception when I try to run. 我练习了whit spring框架和数据库(PostgreSQL),我得到了表格IntelliJ(模块JPA),当我尝试运行时,我有这个例外。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: property mapping has wrong number of columns: com.whoim.bootloader.entitys.TblConversation.tblUsersByCreatorIdConversation type: com.whoim.bootloader.entitys.TblUsers

I generate this code from persistence on IntelliJ ( Modules JPA ) and refactor whit Lombok 我从IntelliJ(模块JPA)上的持久化生成此代码并重构whitok

package com.whoim.bootloader.entitys;

    import lombok.*;

    import javax.persistence.*;
    import java.sql.Timestamp;
    import java.util.Collection;

    @Data
    @Entity
    @Table(name = "tbl_conversation", schema = "public", catalog = "d1fu1ri15o3ia3")
    public class TblConversation {
        @Id@Column(name = "id_conversation")
        private int idConversation;
        @Basic@Column(name = "conversation_title")
        private String conversationTitle;
        @Basic@Column(name = "creator_id_conversation")
        private int creatorIdConversation;
        @Basic@Column(name = "conversation_channel_id")
        private String conversationChannelId;
        @Basic@Column(name = "conversation_created_at")
        private Timestamp conversationCreatedAt;
        @Basic@Column(name = "conversation_updated_at")
        private Timestamp conversationUpdatedAt;
        @Basic@Column(name = "conversation_deleted_at")
        private Timestamp conversationDeletedAt;

        @ManyToOne
        @JoinColumns({
                @JoinColumn(name = "creator_id_conversation", referencedColumnName = "id_user", nullable = false, insertable = true, updatable = true),
                @JoinColumn(name = "creator_id_conversation", referencedColumnName = "id_user", nullable = false)})
        private TblUsers tblUsersByCreatorIdConversation;

        @OneToMany(mappedBy = "tblConversationByDeletedConversationsConversationId")
        private Collection<TblDeletedConversations> tblDeletedConversationsByIdConversation;
        @OneToMany(mappedBy = "tblConversationByConversationIdMessages")
        private Collection<TblMessages> tblMessagesByIdConversation;
        @OneToMany(mappedBy = "tblConversationByConversationIdParticipants")
        private Collection<TblParticipants> tblParticipantsByIdConversation;

    }

I think your mapping should, as per standards, as follows: 我认为你的映射应该按照标准如下:

    @Basic@Column(name = "creator_id_conversation", insertable=false, updatable=false)
    private int creatorIdConversation;

    @ManyToOne
    @JoinColumn(name = "creator_id_conversation"
              , referencedColumnName = "id_user", nullable = false)})
    private TblUsers tblUsersByCreatorIdConversation;

暂无
暂无

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

相关问题 org.hibernate.MappingException:属性映射在ENUM实体中具有错误的列数 - org.hibernate.MappingException: property mapping has wrong number of columns in ENUM entity 由以下原因引起:org.hibernate.MappingException:属性映射的列数错误: - Caused by: org.hibernate.MappingException: property mapping has wrong number of columns: org.hibernate.MappingException:集合外键映射的列数错误 - org.hibernate.MappingException: collection foreign key mapping has wrong number of columns org.hibernate.MappingException Hibernate 映射列 - org.hibernate.MappingException Hibernate mapping columns 引起:org.hibernate.MappingException:无法确定类型:时间戳,列:[org.hibernate.mapping.Column(***)] - Caused by: org.hibernate.MappingException: Could not determine type for: Timestamp, for columns: [org.hibernate.mapping.Column(***)] org.hibernate.MappingException:无法确定以下类型:表:对于列:[org.hibernate.mapping.Column(plant) - org.hibernate.MappingException: Could not determine type for: at table: for columns: [org.hibernate.mapping.Column(plant) JPA映射注释错误org.hibernate.MappingException:外键必须具有与引用的主键相同的列数 - JPA mapping annotation error org.hibernate.MappingException: Foreign key must have same number of columns as the referenced primary key org.hibernate.MappingException:实体的映射中重复的列用于OneToOne映射 - org.hibernate.MappingException: Repeated column in mapping for entity for OneToOne Mapping Hibernate org.hibernate.MappingException - Hibernate org.hibernate.MappingException org.hibernate.MappingException:实体映射中的重复列 - org.hibernate.MappingException: Repeated column in mapping for entity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM