Entering a row referencing a uuid column

How do I enter a row in the editor that references a different table with a UUID as key?

I'm using H2 and have two tables:

CREATE TABLE COMPANIES (
ID UUID DEFAULT RANDOM_UUID() PRIMARY KEY,
NAME VARCHAR(255) NOT NULL
);

and

CREATE TABLE USERS (
EMAIL VARCHAR(255) PRIMARY KEY,
PASSWORD VARCHAR(255) NOT NULL,
COMPANY UUID NOT NULL,
FOREIGN KEY (COMPANY) REFERENCES COMPANIES (ID)
);

When I try to manually enter a new column in the USERS table and paste a valid company id into column COMPANY it gives me a reference error. Perhaps because the entered string isn't cast to a UUID? I'm very sure I entered a valid id from COMPANY.

INSERT INTO "PUBLIC"."USERS" ("EMAIL", "PASSWORD", "COMPANY") VALUES (?, ?, ?);
[23506][23506] Referential integrity constraint violation: "CONSTRAINT_4D: PUBLIC.USERS FOREIGN KEY(COMPANY) REFERENCES PUBLIC.COMPANIES(ID) ('36343861-3366-3832-2d36-3531312d3436')"; SQL statement:
INSERT INTO "PUBLIC"."USERS" ("EMAIL", "PASSWORD", "COMPANY") VALUES (?, ?, ?) [23506-192]

0
3 comments

What is solution for this?

 

0

Prakharvishnoi3

There are 2 separate issues, so please clarify yours and provide more information about it.

0

Please sign in to leave a comment.