New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
H2 dialect should cast binary data of unknown length as VARBINARY, not as BINARY #15195
Comments
Thank you for your report. Can you post the code of your |
import org.apache.commons.lang3.SerializationUtils;
import org.jooq.impl.AbstractConverter;
import java.util.HashMap;
import java.util.Map;
public class HashMapConverter extends AbstractConverter<Object, Map<String, Long>> {
public static final HashMapConverter INSTANCE = new HashMapConverter();
@SuppressWarnings("unchecked")
public HashMapConverter() {
super(Object.class, (Class<Map<String, Long>>) (Class<?>) Map.class);
}
@Override
public Object to(Map<String, Long> m) {
return SerializationUtils.serialize((HashMap) m);
}
@Override
public Map<String, Long> from(Object o) {
if (o == null) {
return null;
}
// If the object is already a map then return it, else deserialize from bytes.
if (o instanceof Map) {
return (Map<String, Long>) o;
}
return SerializationUtils.deserialize((byte[]) o);
}
} |
@lukaseder, I posted the |
Yeah, wrong button, sorry. I'll look into it soon |
I can reproduce this issue. Regarding:
That select "ID" from final table (/* [#12925] 6903578c-469f-4291-aa9b-f9334a791d45 */
merge into "PUBLIC"."T_15195"
using (
select
cast(? as int) "ID",
cast(? as binary) "MAP" -- This looks correct
) "t" on "PUBLIC"."T_15195"."ID" = "t"."ID"
when matched then update set
"PUBLIC"."T_15195"."ID" = "t"."ID",
"PUBLIC"."T_15195"."MAP" = "t"."MAP"
when not matched then insert ("ID", "MAP")
values ("t"."ID", "t"."MAP")
) "T_15195" The reason must be something else. |
The problem is likely the cast as |
Fixed in versions:
Note that in my opinion, a better approach would be to declare the column as |
Expected behavior
A HashMap serialized as bytes should be inserted as bytes.
Actual behavior
The data cannot be deserialized. Looks like the toString() of the byte array was inserted.
Steps to reproduce the problem
DDL:
ts_map column uses a converter.
The converter
to
method serializes to a byte[] and thefrom
method deserializes to a Map<String, Long>.Code:
jOOQ Version
3.18.4
Database product and version
2.1.212
Java Version
No response
OS Version
No response
JDBC driver name and version (include name if unofficial driver)
No response
The text was updated successfully, but these errors were encountered: