2011-03-23 5 views
0

MyBatis Generator 1.3.1을 사용하여 Mapper.xml 파일을 만들었습니다.생성 된 파일의 MyBatis 예외

Exception in thread "main" org.apache.ibatis.builder.BuilderException: Unknown element <#comment> in SQL statement. 
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseDynamicTags(XMLStatementBuilder.java:83) 
    at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:43) 
    at org.apache.ibatis.session.Configuration.parseStatementNodes(Configuration.java:513) 
    at org.apache.ibatis.session.Configuration.buildStatementsForNamespace(Configuration.java:502) 
    at org.apache.ibatis.session.Configuration.buildStatementsFromId(Configuration.java:467) 
    at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:391) 
    at org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:160) 
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:48) 
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:37) 
    at $Proxy1.selectByExample(Unknown Source) 

parseDynamicTags가 < #comment> 필드를 인식하지 못합니다 : MyBatis로는 매퍼 파일을 구문 분석 할 때, 그것은 BuilderException가 발생합니다.

<select id="selectByExample" resultMap="BaseResultMap" parameterType="test.model.TblPosStageExample" > 
    <!--  WARNING - @mbggenerated .. --> 
    select 
    <if test="distinct" > 
     distinct 
    </if> 
    <include refid="Base_Column_List" /> 
    from tbl_Pos_Stage 
    <if test="_parameter != null" > 
     <include refid="Example_Where_Clause" /> 
    </if> 
    <if test="orderByClause != null" > 
     order by ${orderByClause} 
    </if> 
    </select> 

MyBatis로 첫 번째 주석 및 선택 문을 구문 분석 한 것으로 보인다는 분석 된 XML의 일부는 selectByExample입니다. 방금 #text 유형의 노드를 구문 분석했지만 #comment의 출처가 확실하지 않습니다.

나는 생성 된 파일을 수정하지 않았으며, 과거에 올바르게 작동하고 갑자기 중단되었다는 것을 당혹 스럽다.


편집 : Base_column_list

여기
<sql id="Base_Column_List" > 
    <!-- 
     WARNING - @mbggenerated 
     This element is automatically generated by MyBatis Generator, do not modify. 
     This element was generated on Wed Mar 23 08:04:42 EST 2011. 
    --> 
    SurrogatePK, businessDate, positionId, busAIdCode, {95 columns deleted for brevity} 
    marketValueCcy, settledMarketValueCcy 
    </sql> 

그리고이 문제의 원인을 내가 알아 낸 한 example_where_clause

<sql id="Example_Where_Clause" > 
    <!-- 
    WARNING - @mbggenerated 
    This element is automatically generated by MyBatis Generator, do not modify. 
    This element was generated on Wed Mar 23 08:04:42 EST 2011. 
    --> 
    <where > 
    <foreach collection="oredCriteria" item="criteria" separator="or" > 
    <if test="criteria.valid" > 
     <trim prefix="(" suffix=")" prefixOverrides="and" > 
     <foreach collection="criteria.criteria" item="criterion" > 
     <choose > 
     <when test="criterion.noValue" > 
      and ${criterion.condition} 
     </when> 
     <when test="criterion.singleValue" > 
      and ${criterion.condition} #{criterion.value} 
     </when> 
     <when test="criterion.betweenValue" > 
      and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} 
     </when> 
     <when test="criterion.listValue" > 
      and ${criterion.condition} 
      <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," > 
      #{listItem} 
      </foreach> 
     </when> 
     </choose> 
     </foreach> 
     </trim> 
    </if> 
    </foreach> 
    </where> 
</sql> 
+0

"Base_Column_List"및 "Example_Where_Clause"참조에 xml을 제공 할 수 있습니까? 오류는 그 중 하나에서 발생한 것일 수 있습니다. – TheClair

+0

@TheClair, OK, 질문을 편집하여 추가했습니다. – rajah9

+0

죄송합니다. 아무 것도 내게 튀어 나와 없습니다. :(나는 그것이 어디에 걸리는지를 격리시키기 위해 쿼리를 수정하는 것이 좋겠지 만 이미 시도해 보았을 것입니다. – TheClair

답변

1

입니다. (myBatis 생성 프로세스와 아무런 관련이 없습니다.)

많은 오래된 패키지가 포함 된 타사 라이브러리가 포함 된 Eclipse 빌드 경로에 유틸리티 패키지를 추가 할 때 문제가 발생했습니다. 문제가되는 패키지가 오래된 org.apache.xerces.parsers라고 생각합니다.

Eclipse 프로젝트를 처음부터 빌드하고 패키지와 코드를 한 번에 하나씩 추가하여 오류를 발견했습니다.

런타임 오류 (SQL 문에서 알 수없는 요소 < #comment>)는 프로젝트를 추가하여 재현 할 수 있으며 빌드 경로에서 프로젝트를 제거하여 제거 할 수 있습니다.

1

대체 할 수없는 표준이 아닌 XML 파서로 인해 같은 문제가 발생합니다. MyBatis issue management에 문제를 열었으며 패치를 첨부했습니다. 희망이 곧 수정 될 것입니다.

편집 : 문제가 r5388에서 해결되었습니다.

관련 문제