Skip to content

[OPENJPA-3020] Choose the LOB type of a converted attribute from the converter - #222

Merged
solomax merged 3 commits into
masterfrom
OPENJPA-3020
Oct 25, 2026
Merged

solomax merged 3 commits into
masterfrom
OPENJPA-3020

Conversation

@rzo1

@rzo1 rzo1 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Reported by @ilgrosso while testing Apache Syncope against 4.2.0-SNAPSHOT on PostgreSQL: @Lob @Convert(converter = ProvisionListConverter.class) private List<Provision> provisions, with an AttributeConverter<List<Provision>, String>, gave a BYTEA column, where Syncope 4.1 with @Lob private String provisions gave TEXT.

@Lob and <lob/> set the column to CLOB for a String, char[] or Character[] attribute and to BLOB otherwise. The mapping parsers do this before the converter is known, and MappingInfo keeps that type over the converter's template column. So a converter to String on any other attribute type got a BLOB, and a converter to byte[] on a String got a CLOB. On Derby the insert fails with XCL12. This is not new: a converted attribute that is not a collection has the same problem on master and in 4.1.1. OPENJPA-3017 only made the List case reachable.

ConverterValueHandler and ConverterElementHandler now change a CLOB or BLOB column to CLOB for a converter to String and to BLOB for a converter to byte[]. Other database types keep their column type. This covers annotations, mapping files, overrides and auto-applied converters, because the handlers run once the converter is known. A converter to byte[] is also read as bytes now; before, the converter was passed a java.sql.Blob and failed with "argument type mismatch", with or without @Lob.

The tests use a List converted as a whole, so this PR is based on #220 (OPENJPA-3017) and will move to master once that is merged.

Existing tables created with @Lob and a converter to String have a BLOB column, while the mapping now expects a CLOB.

Base automatically changed from OPENJPA-3017 to master October 24, 2026 02:00
rzo1 added 2 commits October 24, 2026 09:43
…converter

@lob and <lob/> made a CLOB for a String, char[] or Character[] attribute
and a BLOB otherwise, before the converter was known, and the converter's
template column did not override it. A converter to String on any other
attribute type therefore got a BLOB, and a converter to byte[] on a String
a CLOB. The converter handlers now set the LOB type from the converter's
database type. A byte[] database type is also read as bytes, so the
converter no longer gets a java.sql.Blob.
@solomax
solomax merged commit a6faa27 into master Oct 25, 2026
4 checks passed
@solomax
solomax deleted the OPENJPA-3020 branch October 25, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants