JpaRepository: {quote}@Query("SELECT new ReportConfig(rc.uuid, rc.accountId, rc.createDate, rc.modifiedDate, author.id, :userId, author.firstName, author.lastName, rc.title ) FROM ReportConfig rc " + ... ) List<ReportConfig> findByAccountIdAndUserId(@Param("accountId") Long accountId, @Param("userId") Long userId );{quote}
Constructor: {quote}public ReportConfig( String uuid, Long accountId, Date createDate, Date modifiedDate, Long ownerId, Long userId, String firstName, String lastName, String title) \ { // other stuff } {quote}
Exception: {quote}Unable to locate appropriate constructor on class ... Expected arguments are: java.lang.String, long, java.util.Date, java.util.Date, long, java.lang.String, java.lang.String, java.lang.String{quote}
As you can see :userId is not recognized as Long input parameter for the constructor.
Clearly the {{JPQL BNF}} *does* permit passing parameters as constructor arguments.
{code}constructor_expression ::= NEW constructor_name ( constructor_item {, constructor_item}* ) constructor_item ::= single_valued_path_expression | scalar_expression | aggregate_expression | identification_variable scalar_expression ::= simple_arithmetic_expression | string_primary | enum_primary | datetime_primary | boolean_primary | case_expression | entity_type_expression string_primary ::= state_field_path_expression | string_literal | input_parameter | functions_returning_strings | aggregate_expression | case_expression{code}
|
|