我有表mwallet_terminal_store_mapping,其中tid(字符变体)是主键,而外键则指向terminal_master中的一列tid。
在terminal_master中,tid(即字符变体)是唯一键。并且它的PK ID很长。

现在,我具有第一个表mapping_details的DTO,其定义如下。

    private TerminalMaster terminalMaster;

    @OneToOne
@JoinColumn(name="pine_tid", referencedColumnName = "tid")
public TerminalMaster getTerminalMaster() {
    return terminalMaster;
}

public void setTerminalMaster(TerminalMaster terminalMaster) {
    this.terminalMaster = terminalMaster;
}


第一个表的架构:

 CREATE TABLE mwallet_terminal_store_mapping
 (
pine_tid character varying(8) NOT NULL,
pine_sid bigint NOT NULL,
pine_mid text NOT NULL,
fis_tid text NOT NULL,
fis_sid text NOT NULL,
fis_mid text NOT NULL,
date_created timestamp without time zone,
date_modified timestamp without time zone,
created_by text,
modified_by text,
status text,
rfu1 text,
rfu2 text,
rfu3 text,
rfu4 text,
rfu5 text,
CONSTRAINT mwallet_terminal_store_mapping_pkey PRIMARY KEY (pine_tid),
CONSTRAINT fk_mwallet_terminal_store_mapping_pinesid FOREIGN KEY (pine_sid)
    REFERENCES store_master (id) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE NO ACTION,
   CONSTRAINT fk_mwallet_terminal_store_mapping_pinetid FOREIGN KEY (pine_tid)
    REFERENCES terminal_master (tid) MATCH SIMPLE
    ON UPDATE NO ACTION ON DELETE NO ACTION
    )


第二张表的架构:

CREATE TABLE terminal_master
(
id bigint NOT NULL DEFAULT nextval('terminal_master_seq'::regclass),
tid character varying(8),
store_master_id bigint,
status integer,
inserted_on timestamp without time zone,
modified_on timestamp without time zone,
offline_floor_limit character varying(20),
enable_redeem integer DEFAULT 1,
enable_load_activate integer DEFAULT 1,
enable_offline integer DEFAULT 1,
enable_balance_enquiry integer DEFAULT 1,
enable_format_validation integer DEFAULT 1,
enable_category_validation integer DEFAULT 1,
enable_category_popup integer DEFAULT 1,
enable_prepaid_load integer DEFAULT 1,
enable_prepaid_reload integer DEFAULT 1,
rfu1 character varying(20),
rfu2 character varying(20),
rfu3 character varying(20),
block_status integer DEFAULT 0,
enable_gf_redeem integer DEFAULT 0,
externalid character varying(15),
fis_tid text,
licence_id text,
CONSTRAINT terminal_master_pkey PRIMARY KEY (id),
CONSTRAINT fk_terminal_master_1 FOREIGN KEY (store_master_id)
  REFERENCES store_master (id) MATCH SIMPLE
  ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT uq_terminal_master_1 UNIQUE (tid)
)


现在的问题是,当我尝试根据tid在第一个表中执行搜索时,

它说SQLGrammer异常,因为不存在运算符:字符varing = bigint。

这意味着它仍在尝试将我的字符串与terminal_master的主键进行比较,
我没有提到这个。

请澄清。

最佳答案

这里的TerminalMaster实体具有“ ID”是主键,因此您的映射将像这样

private TerminalMaster terminalMaster; @OneToOne@JoinColumn(name="pine_tid", referencedColumnName = "id")public TerminalMaster getTerminalMaster() { return terminalMaster;}public void setTerminalMaster(TerminalMaster terminalMaster) { this.terminalMaster = terminalMaster;}


唯一约束将不是引用列名称。

关于java - 数据未从唯一字段上的外键表中获取,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5539253/

10-10 20:22