2015-02-23 41 views
1

因此時常我收到此錯誤,大多是由機器人引起:查詢不被列名的可轉位,但該列不應該存在

java.lang.IllegalArgumentException: 
    [Table (rows 0 columns ID, BOOKID, EDITIONID, EDITIONNAME, PRACTICEAREALINK, PUBLISHED): 
    ...REALINK: [email protected]] 
    [PUBLISHED: [email protected]] ] is not indexable by webtypeid 

但是要找到它指的是無處列在試圖引用的查詢中。

所以我們在這裏播放3個文件,一個index.cfm,一個Business.cfc和一個DAO.cfc。在業務代碼看起來像:

<cfcomponent extends="_lbr._core.NativeBusiness"> 
    <cffunction name="init" access="public" output="false" returntype="_lbr._who._publication._Edition.EditionBusiness" hint="Pseudo-constructor"> 
    <cfargument name="oEditionDAO"   type="_lbr._who._publication._Edition.EditionDAO"   required="true"> 
    <cfscript> 
     super.init(argumentCollection=arguments); 

     variables.oEditionDAO  = arguments.oEditionDAO; 

     return this; 
    </cfscript> 
    </cffunction> 

    <cffunction name="getEditionByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nEditionID" type="numeric" required="false"> 
    <cfargument name="nPraciceAreaID" type="numeric" required="false"> 
    <cfargument name="bPublished" type="boolean" required="false"> 
    <cfscript> 
     return variables.oEditionDAO.getEditionByPracticeArea(argumentCollection=arguments); 
    </cfscript> 
    </cffunction> 

    <cffunction name="getEditionsByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nPracticeAreaID" type="numeric" required="false"> 
    <cfargument name="bPracticeAreaLink" type="boolean" required="false"> 
    <cfargument name="bPublished" type="boolean" required="false"> 
    <cfargument name="lstFields" type="string" required="false"> 
    <cfscript> 
     return variables.oEditionDAO.getEditionsByPracticeArea(argumentCollection=arguments); 
    </cfscript> 
    </cffunction> 

    <cffunction name="getTypesByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nPracticeAreaID" type="numeric" required="false"> 
    <cfargument name="nEditionID" type="numeric" required="false"> 
    <cfscript> 
     return variables.oEditionDAO.getTypesByPracticeArea(argumentCollection=arguments); 
    </cfscript> 
    </cffunction> 

</cfcomponent> 

沒有什麼特別不尋常的。

的DAO看起來像

<cfcomponent extends="_lbr._core.NativeDAO"> 
    <cffunction name="init" access="public" output="false" returntype="_lbr._who._Publication._Edition.EditionDAO" hint="Pseudo-constructor"> 
    <cfargument name="sDSN" type="string" required="true" hint="The datasource name to use to access the database through."> 
    <cfargument name="oCFML"   type="_lbr._util._cfml.CFML" required="true" hint="The CFML object to use for scripting."> 
    <cfscript> 
     super.init(argumentCollection=arguments); 
     variables.sDSN     = arguments.sDSN; 
     variables.oCFML     = arguments.oCFML; 
     variables.lstFields    = "p.publication_ID, p.publication_name, e.edition_id, e.edition_name, e.pub_year, e.pub_date"; 
     variables.lstSubEditionFields = "id,bookid,editionid,editionname,practiceareaLink,published"; 
     return this; 
    </cfscript> 
    </cffunction> 

    <cffunction name="getEditionByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nEditionID" type="numeric" required="false"> 
    <cfargument name="nPraciceAreaID" type="numeric" required="false"> 
    <cfargument name="bPublished" type="boolean" required="false"> 
    <cfargument name="nStartRow" required="true" type="numeric" default="0"> 
    <cfargument name="nEndRow" required="true" type="numeric" default="1"> 
    <cfscript> 
     return selectEditionsByPracticeArea(argumentCollection=arguments); 
    </cfscript> 
    </cffunction> 

    <cffunction name="getEditionsByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nPracticeAreaID" type="numeric" required="false"> 
    <cfargument name="bPracticeAreaLink" type="boolean" required="false"> 
    <cfargument name="bPublished" type="boolean" required="false"> 
    <cfargument name="lstFields" type="string" required="false"> 
    <cfscript> 
     return selectEditionsByPracticeArea(argumentCollection=arguments); 
    </cfscript> 
    </cffunction> 

    <cffunction name="selectEditionsByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nStartRow" required="true" type="numeric" default="0"> 
    <cfargument name="nEndRow" required="true" type="numeric" default="100"> 
    <cfargument name="nEditionID" type="numeric" required="false" default="0"> 
    <cfargument name="nPracticeAreaID" type="numeric" required="false" default="0"> 
    <cfargument name="bPracticeAreaLink" type="boolean" required="false"> 
    <cfargument name="bPublished" type="boolean" required="false"> 
    <cfargument name="lstFields" type="string" default="#variables.lstSubEditionFields#" required="false"> 
    <cfquery name="qQuery" datasource="#variables.sDSN#"> 
     SELECT #arguments.lstFields# 
      FROM tbl_who_subeditions 
     WHERE 1 
     <cfif arguments.nPracticeAreaID gt 0> 
      AND bookid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nPracticeAreaID#"> 
     </cfif> 
     <cfif arguments.nEditionID gt 0> 
      AND editionID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nEditionID#"> 
     </cfif> 
     <cfif structKeyExists(arguments,"bPublished")> 
      AND published = <cfqueryparam cfsqltype="cf_sql_bit" value="#arguments.bPublished#"> 
     </cfif> 
     <cfif arguments.nPracticeAreaID gt 0 OR arguments.nEditionID gt 0> 
      <cfif structKeyExists(arguments,"bPracticeAreaLink")> 
       AND practiceareaLink = <cfqueryparam cfsqltype="cf_sql_tinyint" value="#arguments.bPracticeAreaLink#"> 
      </cfif> 
     </cfif> 
     LIMIT #arguments.nStartRow#,#arguments.nEndRow# 
    </cfquery> 
    <cfreturn qQuery> 
    </cffunction> 

    <cffunction name="getTypesByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nPracticeAreaID" type="numeric" required="false"> 
    <cfargument name="nEditionID" type="numeric" required="false"> 
    <cfscript> 
     return selectTypesByPracticeArea(argumentCollection=arguments); 
    </cfscript> 
    </cffunction> 

    <cffunction name="selectTypesByPracticeArea" returntype="query" access="public"> 
    <cfargument name="nStartRow" required="true" type="numeric" default="0"> 
    <cfargument name="nEndRow" required="true" type="numeric" default="100"> 
    <cfargument name="nEditionID" type="numeric" required="false" default="0"> 
    <cfargument name="nPracticeAreaID" type="numeric" required="false" default="0"> 
    <cfargument name="lstFields" type="string" default="#variables.lstSubEditionFields#" required="false"> 
    <cfquery name="qQuery" datasource="#variables.sDSN#"> 
     SELECT distinct webtypeid, typename 
      FROM tbl_who_webtype2practiceareas wp 
      JOIN tbl_who_webtypes w ON wp.webtypeid = w.id 
     WHERE 1 
     <cfif arguments.nPracticeAreaID gt 0> 
      AND bookid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nPracticeAreaID#"> 
     </cfif> 
     <cfif arguments.nEditionID gt 0> 
      AND editionid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.nEditionID#"> 
     </cfif> 
     LIMIT #arguments.nStartRow#,#arguments.nEndRow# 
    </cfquery> 
    <cfreturn qQuery> 
    </cffunction> 
</cfcomponent> 

這是不尋常這裏的唯一的事情就是selectTypesByPracticeArea有一個lstFields違約與variables.lstSubEditionFields,但因爲它沒有被在該函數中使用,它不應該證明一個問題

所以index.cfm只是有

variables.stArgs = {}; 
variables.stArgs.nPracticeAreaID = request.parameters.nPublicationID; 
variables.stArgs.nEditionID = request.parameters.nSubEdition; 

variables.qTypes = application.stObj.oEditionBusiness.getTypesByPracticeArea(argumentCollection=variables.stArgs); 

if(variables.qTypes["webtypeid"].IndexOf(JavaCast("int",2)) GTE 0 OR variables.qTypes["webtypeid"].IndexOf(JavaCast("int",3)) GTE 0){ 
    request.parameters.bHasTypes = true; 
} 

上發生的錯誤if語句。它應該只接收包含webtypeidtypename的查詢,那麼它在哪裏認爲它從ID, BOOKID, EDITIONID, EDITIONNAME, PRACTICEAREALINK, PUBLISHED?我所能理解的是,它與前場混淆......但這沒有任何意義。

+0

有錯誤處理代碼發送給您的變量cfdump。 qTypes – 2015-02-23 17:28:34

回答

3

乍一看我懷疑這是因爲你沒有使用var來聲明qQuery本地函數,所以它在執行這些方法時被覆蓋。如果您在CFQUERY標籤之前,試試這個,你可能會看到它消失:

<cfset var qQuery = "">

您也可以使用本地範圍爲local.qQuery

+0

是的 - 競賽條件。他們以這種有趣的方式表現自己;-) +1。 – Leigh 2015-02-23 23:26:37

+0

我認爲這可能是,明天將不得不嘗試。也@Leigh你不能+1自己;) – Jarede 2015-02-23 23:38:33

+0

(編輯)哈哈,不太符合我的風格。我正在考慮種族條件,但是.. ndintenfass打我回答。所以*他*得到「+1」;-) – Leigh 2015-02-23 23:55:38

相關問題