Repository navigation
[OPENJPA-3020] Choose the LOB type of a converted attribute from the converter - #222
Merged
Merged
Conversation
…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.
…e migration considerations
solomax
reviewed
Oct 24, 2026
solomax
approved these changes
Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported by @ilgrosso while testing Apache Syncope against 4.2.0-SNAPSHOT on PostgreSQL:
@Lob @Convert(converter = ProvisionListConverter.class) private List<Provision> provisions, with anAttributeConverter<List<Provision>, String>, gave aBYTEAcolumn, where Syncope 4.1 with@Lob private String provisionsgaveTEXT.@Loband<lob/>set the column to CLOB for aString,char[]orCharacter[]attribute and to BLOB otherwise. The mapping parsers do this before the converter is known, andMappingInfokeeps that type over the converter's template column. So a converter toStringon any other attribute type got a BLOB, and a converter tobyte[]on aStringgot a CLOB. On Derby the insert fails withXCL12. 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 theListcase reachable.ConverterValueHandlerandConverterElementHandlernow change a CLOB or BLOB column to CLOB for a converter toStringand to BLOB for a converter tobyte[]. 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 tobyte[]is also read as bytes now; before, the converter was passed ajava.sql.Bloband failed with "argument type mismatch", with or without@Lob.The tests use a
Listconverted 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
@Loband a converter toStringhave a BLOB column, while the mapping now expects a CLOB.