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>
"Base_Column_List"및 "Example_Where_Clause"참조에 xml을 제공 할 수 있습니까? 오류는 그 중 하나에서 발생한 것일 수 있습니다. – TheClair
@TheClair, OK, 질문을 편집하여 추가했습니다. – rajah9
죄송합니다. 아무 것도 내게 튀어 나와 없습니다. :(나는 그것이 어디에 걸리는지를 격리시키기 위해 쿼리를 수정하는 것이 좋겠지 만 이미 시도해 보았을 것입니다. – TheClair