jOOQ 子查询给出编译错误“SelectWhereStep 类型中的方法 where(Condition...)...不适用于参数

jOOQ Subquery gives compile error "The method where(Condition...) in the type SelectWhereStep....is not applicable for the arguments

我在子查询的 .where 上收到以下编译器错误 (.where( parentHelp.SUBJECT_ID = IFS_HELP.PARENT_SUBJECT_ID )):

The method where(Condition...) in the type SelectWhereStep<Record1<String>> is not applicable for the arguments (TableField<IfsHelpRecord,Long>)

当我有以下 jOOQ 子查询代码时:

        IfsHelp parentHelp = IFS_HELP.as( "parentHelp" );

        Field<Object> parent_help_subject = sqlca   .select( IFS_HELP.SUBJECT_NAME )
                                                    .from( parentHelp )
                                                    .where( parentHelp.SUBJECT_ID = IFS_HELP.PARENT_SUBJECT_ID )
                                                    .asField( "parent_help_subject" );

        results = sqlca .select( IFS_HELP.SUBJECT_NAME, IFS_HELP.SUBJECT_ID, parent_help_subject )
                        .from( IFS_HELP )
                        .where( IFS_HELP.HELP_TEXT.like( argument ) )
                        .and( IFS_HELP.DISPLAY.equal( "Y" ) )
                        .orderBy( IFS_HELP.SUBJECT_NAME.asc() )
                        .limit( 50 )
                        .fetch();

数据库 table 如下所示:

IFS_HELP
  SUBJECT_ID (bigint, pk)
  SUBJECT_NAME (varchar)
  PARENT_SUBJECT_ID (bigint, fk back to ifs_help.subject_id)
  HELP_TEXT (varchar)
  DISPLAY (char)

这是我要执行的查询:

   SELECT         ifs_help.subject_name,   
                        ifs_help.subject_id,
                        ifs_isNull( ( select subject_name from ifs_help P where P.subject_id = ifs_help.parent_subject_id ), '' ) as parent_help_subject  
         FROM       ifs_help  
         WHERE      ifs_help.help_text like argument
            AND     ifs_help.display = 'Y'
         ORDER BY   ifs_help.subject_name ASC  
         LIMIT 50 

这是一个简单的错字。如果在像 jOOQ 这样的内部 DSL 中可以实现以下功能,那就太好了:

.where( parentHelp.SUBJECT_ID = IFS_HELP.PARENT_SUBJECT_ID )
//                            ^ Redefined semantics of assignment operator

但事实并非如此。您不能在 Java 中重新定义赋值运算符的语义。所以你必须改用 eq() or equal() 方法:

.where( parentHelp.SUBJECT_ID.eq(IFS_HELP.PARENT_SUBJECT_ID) )