Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4266678
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:47:37+00:00 2026-05-21T06:47:37+00:00

I used MyBatis Generator 1.3.1 to create a Mapper.xml file. When MyBatis parses the

  • 0

I used MyBatis Generator 1.3.1 to create a Mapper.xml file. When MyBatis parses the Mapper file, it throws a BuilderException:

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 is not recognizing the <#comment> field. The portion of the XML that it is parsing is selectByExample:

  <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 seems to have parsed the first comment and the select statement. It has just parsed a node of type #text, but I am not sure where the #comment comes from.

I have not modified the generated file, and I am puzzled that this has functioned correctly in the past and stopped suddenly.


EDIT: 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>

And here is the 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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T06:47:38+00:00Added an answer on May 21, 2026 at 6:47 am

    I have figured out what caused this problem. (It had nothing to do with the myBatis generation process.)

    The problem occurred when I added a utility package to my Eclipse build path, which included a third party library that had many old packages. I suspect that the offending package is an old org.apache.xerces.parsers.

    I found the error by building the Eclipse project from scratch and adding packages and code, one at a time.

    The runtime error (Unknown element <#comment> in SQL statement) could be reproduced by adding the Project and eliminated by removing the Project from the Build Path.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the phonegap website to create an IPA file. Now I want to
I used Putty Key Generator to create a private key, called Putty-Private.ppk . I
I'm upgrading from iBatis 2.x to myBatis 3.0.6 and I have a mapper file
I used TOAD for oracle 11g, I want to create an insert script from
Used the create unit tests tool in Visual Studio and obviously it tries to
I am using Spring 3.0.3, MyBatis 3.0.2 and mybatis-spring 1.0.0 on Apache Tomcat 6.0.29.
Used http://www.ilbcfreeware.org/software.html - I only get static from the files that ilbc_test.exe creates. Does
Used XStream lib, but no children XML was difficult to parse in Java. Wanting
used to Apache in Linux where each domain name using ssl requires its own
... used in orderscontroller#new to create an array, which is used in a select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.