简体   繁体   中英

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

I receive the following compiler error on the .where of the subquery ( .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>)

when I have the following jOOQ subquery code:

  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(); 

The database table looks like this:

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)

This is the query I am trying to execute:

  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 

This is a simple typo. It would be great if the following were possible in an internal DSL like jOOQ:

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

But it isn't. You cannot redefine the semantics of the assignment operator in Java. So you have to use the eq() or equal() method instead:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM