與this question類似,我想使用我自己的用戶定義類型「AccountNumber」執行SQL「like」操作。QueryDSL like operation SimplePath
的QueryDSL實體類定義了列的字段是這樣的:
public final SimplePath<com.myorg.types.AccountNumber> accountNumber;
我曾嘗試下面的代碼,實現了「喜歡」的SQL操作,但在類型前相比得到一個錯誤運行查詢:
final Path path=QBusinessEvent.businessEvent.accountNumber;
final Expression<AccountNumber> constant = Expressions.constant(AccountNumber.valueOfWithWildcard(pRegion.toString()));
final BooleanExpression booleanOperation = Expressions.booleanOperation(Ops.STARTS_WITH, path, constant);
expressionBuilder.and(booleanOperation);
的錯誤是:
org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [7!%%] did not match expected type [com.myorg.types.AccountNumber (n/a)]
有沒有人能夠使用QueryDSL/JPA組合實現這一目標?