[
https://issues.apache.org/jira/browse/OPENJPA-3018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18130474#comment-18130474
]
ASF subversion and git services commented on OPENJPA-3018:
----------------------------------------------------------
Commit 14f8e0a3b1bfbe4bad5a2dcf5c299fe74cd94b83 in openjpa's branch
refs/heads/OPENJPA-3018 from Richard Zowalla
[ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=14f8e0a3b ]
[OPENJPA-3018] Do not append a size to JSON and JSONB column definitions
A column definition of jsonb on PostgreSQL, or json on MySQL and MariaDB,
was generated with the column length appended, e.g. jsonb(255), which the
database rejects. These types take no length, so they are now listed as
fixed size types in the three dictionaries.
> Size appended to a JSON or JSONB column definition on PostgreSQL, MySQL and
> MariaDB
> -----------------------------------------------------------------------------------
>
> Key: OPENJPA-3018
> URL: https://issues.apache.org/jira/browse/OPENJPA-3018
> Project: OpenJPA
> Issue Type: Bug
> Affects Versions: 4.1.1
> Reporter: Richard Zowalla
> Assignee: Richard Zowalla
> Priority: Major
>
> A column declared with {{columnDefinition}} (or {{column-definition}} in a
> mapping file) of type {{jsonb}} on PostgreSQL, or {{json}} on MySQL and
> MariaDB, gets the column length appended in the generated DDL. For a
> {{String}} column the default length is 255, so the schema tool emits
> {{jsonb(255)}} and the database rejects the statement:
> {noformat}
> org.apache.openjpa.lib.jdbc.ReportingSQLException: ERROR: type modifier is
> not allowed for type "jsonb"
> CREATE TABLE AnyObject (id VARCHAR(36) NOT NULL, ..., plainAttrs jsonb(255),
> ...)
> {noformat}
> {{DBDictionary.getTypeName(Column)}} passes the column definition through
> {{appendSize()}}, which appends the size unless the type name is in
> {{fixedSizeTypeNameSet}}. {{PostgresDictionary}} does not list {{JSON}} or
> {{JSONB}}, and {{MySQLDictionary}} and {{MariaDBDictionary}} do not list
> {{JSON}}. None of these types takes a length.
> Reported on PR #220 by Francesco Chicchiriccò while testing Apache Syncope
> master against 4.2.0-SNAPSHOT, with this mapping:
> {code:xml}
> <basic name="plainAttrs">
> <column column-definition="jsonb"/>
> </basic>
> {code}
> Syncope 3.x did not hit this because its mapping also declared {{<lob/>}},
> which sets the size to -1.
> Workaround: {{openjpa.jdbc.DBDictionary=postgres(FixedSizeTypeNames=JSONB)}}.
> Fix: add {{JSON}} and {{JSONB}} to the fixed size type names of
> {{PostgresDictionary}}, and {{JSON}} to those of {{MySQLDictionary}} and
> {{MariaDBDictionary}}.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)