openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yves PIEL <ypiel.talend....@gmail.com>
Subject Escape default value on CREATE TABLE
Date Tue, 12 Jun 2018 13:21:42 GMT
Hi,

I try to use JPA to generate CREATE TABLE statements.All works fine but
default values of VARCHAR.

For example, I add a VARCHAR column with default value with :

DBIdentifier name = DBIdentifier.newColumn("na-me");
Column cName = table.addColumn(name);
cName.setType(Types.VARCHAR);
cName.setNotNull(true);
cName.setSize(255);
cName.setDefault("O,K");

And the generated code is:

DB => CREATE TABLE "My-schema".MaTable (id1 INTEGER NOT NULL, id2
VARCHAR(500) NOT NULL, "na-me" VARCHAR(255) DEFAULT O,K NOT NULL, âge
TINYINT DEFAULT 20, salary DECIMAL, CONSTRAINT idkeys PRIMARY KEY (id1,
id2))


'O,K' will corrupt my SQL query. How can I force the escape of default
values ?

Regards,
Yves

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message