First of all, I already tried this JDBI 3: Nested SQLObject and it didn't work
I'm trying basically the same thing as the other person, to gather some nested objects in jdbi 3 but using RegisterConstructorMapper
instead.
This is my code:
ClassA.java
@Value
@AllArgsConstructor
@Jacksonized
@Builder(toBuilder = true)
public class ClassA {
@Nested
ClassB classB;
String someString;
}
ClassB.java
@Value
@AllArgsConstructor
@Jacksonized
@Builder(toBuilder = true)
public class ClassB {
Long id;
}
The code in my dao:
@SqlQuery("""
SELECT
a.some_string as someString,
b.id as b_id
FROM table_a a
INNER JOIN table_b b on a.b_id = b.id
WHERE a.id = :id
""")
@RegisterConstructorMapper(value = ClassB.class, prefix = "b")
@RegisterConstructorMapper(ClassA.class)
Optional<ClassA> findClassA(long id);
But when I run the code I keep getting this error:
Instance factory 'public com.blah.ClassA(com.blah.ClassB,java.lang.String)' parameter '[classB]' has no matching columns in the result set. Verify that the Java compiler is configured to emit parameter names, that your result set has the columns expected, annotate the parameter names explicitly with @ColumnName, or annotate nullable parameters as @Nullable Blockquote Blockquote