Jimmer Version
0.11.0
JDK Version
JDK 21
Database
N/A
OS
Windows
Expected behavior
The DTO compiler reports an error when the filter class does not match the target entity type.
Actual behavior
Compilation of the DTO succeeds. The error surfaces later from javac, in generated code:
BookDeepView.java:115: error: incompatible types: AuthorFilter cannot be converted to FieldFilter<BookTable>
Description
DtoGenerator (KSP) parses the generic argument of KFieldFilter and compares it against the target entity type, throwing DtoException on mismatch. The APT implementation constructs the same GenericParser against FieldFilter and discards the result. The check is missing on the Java side; the error only surfaces from javac, at a line in generated code.
Reproduction steps
dto
export org.babyfish.jimmer.sql.model.Author
import testpkg.configurations.AuthorFilter
BookWithFilter {
!filter(AuthorFilter)
books {
authorFullNames
}
}
entity
@Entity
public interface Author {
@ManyToMany(mappedBy = "authors")
List<Book> books();
}
@Entity
public interface Book {
@ManyToMany
@JoinTable(
name = "BOOK_AUTHOR_MAPPING",
joinColumnName = "BOOK_ID",
inverseJoinColumnName = "AUTHOR_ID",
deletedWhenEndpointIsLogicallyDeleted = true
)
List<Author> authors();
@Formula(dependencies = {"authors.firstName", "authors.lastName"})
default List<String> authorFullNames() {
List<String> fullNames = new ArrayList<>(authors().size());
for (Author author : authors()) {
fullNames.add(author.firstName() + "-" + author.lastName());
}
return fullNames;
}
}
filter
public class AuthorFilter implements FieldFilter<AuthorTable> {
@Override
public void apply(FieldFilterArgs<AuthorTable> args) {
AuthorTable table = args.getTable();
args
.where(
Predicate.and(
table.firstName().ne("Alex"),
table.lastName().ne("Banks")
)
)
.orderBy(
table.firstName().asc(),
table.lastName().asc()
);
}
}
Generated SQL
No response
Relation Model
No response
Screenshots
No response
Logs
No response
Jimmer Version
0.11.0
JDK Version
JDK 21
Database
N/A
OS
Windows
Expected behavior
The DTO compiler reports an error when the filter class does not match the target entity type.
Actual behavior
Compilation of the DTO succeeds. The error surfaces later from javac, in generated code:
Description
DtoGenerator(KSP) parses the generic argument ofKFieldFilterand compares it against the target entity type, throwingDtoExceptionon mismatch. The APT implementation constructs the sameGenericParseragainstFieldFilterand discards the result. The check is missing on the Java side; the error only surfaces from javac, at a line in generated code.Reproduction steps
dto
entity
filter
Generated SQL
No response
Relation Model
No response
Screenshots
No response
Logs
No response