Skip to content

pojoSerDe was not correctly resolved. #2685

Open

Description

@A-little-bit-of-data

Description

Steps to reproduce

1.client-v2 0.9.4
2.The JavaBean has two fields, cs and c_s, each with getter and setter methods. During debugging, the following error was found:

Image

When performing mapping, whether it's cs or c_s, it's always retrieved using getCs().

Error Log or Exception StackTrace

Expected Behaviour

Code Example

Configuration

Client Configuration

Environment

  • Cloud
  • Client version:
  • Language version:
  • OS:

ClickHouse Server

  • ClickHouse Server version:
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Activity

  1. added theissue type on Dec 9, 2025
  2. chernser commented on Dec 9, 2025

    @chernser
    Contributor

    thank you for reporting, @A-little-bit-of-data !
    We will look into it.

  3. added
    data-types
    and removed on Nov 26, 2026
  4. polyglotAI-bot commented on Nov 28, 2026

    @polyglotAI-bot
    Collaborator

    Recommendation: Keep open — fix needed
    Two getters whose names differ only in _ (getCs, getC_s) get one match key, so a POJO insert writes one getter's value into both columns with no error. No open PR fixes it.

    • Category: Bug
    • Classification: impact: Data integrity · area: Data types & formats (POJO serialization)
    • Status on main: Reproduced on main — the insert stores the c_s value in both columns; queryAll with the class never calls setCs.
    • Breaking change: No — can be done without a break, if names that match today keep matching.
    • Duplicates / related: Related: [client-v2] Underscore in column name is removed #1866 (closed) — its fix added the name match that ignores _.
    • Workaround: Give Client.Builder.columnToMethodMatchingStrategy a DefaultColumnToMethodMatchingStrategy that keeps _ (the last two cases of the program).

    Analysis: The default patterns at DefaultColumnToMethodMatchingStrategy.java:29 remove _ from method and column names, so getCs and getC_s both become cs. POJOSerDe.java:44-50 puts the getters and the setters into maps by that key with no collision check, so the method that Class.getMethods() returns last wins (here getC_s; the reporter saw getCs).

    Reproduction: complete program and output
    import com.clickhouse.client.api.Client;
    import com.clickhouse.client.api.metadata.DefaultColumnToMethodMatchingStrategy;
    import com.clickhouse.client.api.metadata.TableSchema;
    import com.clickhouse.client.api.query.GenericRecord;
    import java.util.Collections;
    import java.util.List;
    
    public class Repro {
        static final String URL = System.getenv().getOrDefault("CLICKHOUSE_URL", "http://localhost:8123");
        static final String PASSWORD = System.getenv().getOrDefault("CLICKHOUSE_PASSWORD", "");
    
        public static class Row {
            private String cs;
            private String c_s;
            public Row() {}
            public Row(String cs, String c_s) { this.cs = cs; this.c_s = c_s; }
            public String getCs() { return cs; }
            public void setCs(String cs) { this.cs = cs; }
            public String getC_s() { return c_s; }
            public void setC_s(String c_s) { this.c_s = c_s; }
        }
    
        static void run(String label, Client.Builder builder) throws Exception {
            try (Client client = builder.addEndpoint(URL).setUsername("default").setPassword(PASSWORD).build()) {
                client.execute("DROP TABLE IF EXISTS issue2685").get().close();
                client.execute("CREATE TABLE issue2685 (cs String, c_s String) ENGINE = Memory").get().close();
                TableSchema schema = client.getTableSchema("issue2685");
                client.register(Row.class, schema);
                client.insert("issue2685", Collections.singletonList(new Row("value-of-cs", "value-of-c_s"))).get().close();
                for (GenericRecord r : client.queryAll("SELECT cs, c_s FROM issue2685")) {
                    System.out.println(label + " insert: stored cs=" + r.getString("cs") + ", c_s=" + r.getString("c_s"));
                }
                client.execute("TRUNCATE TABLE issue2685").get().close();
                client.execute("INSERT INTO issue2685 VALUES ('value-of-cs', 'value-of-c_s')").get().close();
                List<Row> rows = client.queryAll("SELECT cs, c_s FROM issue2685", Row.class, schema);
                System.out.println(label + " queryAll: getCs()=" + rows.get(0).getCs() + ", getC_s()=" + rows.get(0).getC_s());
                client.execute("DROP TABLE issue2685").get().close();
            }
        }
    
        public static void main(String[] args) throws Exception {
            run("default strategy:", new Client.Builder());
            // Contrast: the same strategy, but "_" stays in method and column names.
            run("strategy that keeps '_':", new Client.Builder().columnToMethodMatchingStrategy(
                    new DefaultColumnToMethodMatchingStrategy("^(get|is|has).+", "^(set).+", "^(get|set|is|has)", "[-.]")));
        }
    }

    Output on main (8480ca001), ClickHouse 26.11.2.4:

    default strategy: insert: stored cs=value-of-c_s, c_s=value-of-c_s
    default strategy: queryAll: getCs()=null, getC_s()=value-of-c_s
    strategy that keeps '_': insert: stored cs=value-of-cs, c_s=value-of-c_s
    strategy that keeps '_': queryAll: getCs()=value-of-cs, getC_s()=value-of-c_s
    

    Automated triage by Polyglot AI. A maintainer makes the final decision.

  5. added
    client
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclientdata-types

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions