在mybatis的mapper.xml文件中编写了一段SQL语句如下:
我编写的SQL如下:
<!-- 根据角色ID、角色类型、用户ID查询出角色列表--> <select id="getUsersByRoleAuthorize" resultMap="RoleResultMap"> SELECT u.USER_ID, u.user_name, u.user_status, ur.ROLE_ID, r.role_name, ur.ROLE_TYPE, ur.created_by, ur.creation_date, ur.modified_by, ur.modified_date FROM t_user_roles ur,t_user u ,t_roles r WHERE ur.user_id = u.user_id AND r.role_id = ur.role_id <if test="roleAuthorize.roleAuthorizeId != null and roleAuthorize.roleAuthorizeId != ''"> and ur.role_id = #{roleAuthorize.roleAuthorizeId} </if> <if test="roleAuthorize.roleAuthorizeType != null and roleAuthorize.roleAuthorizeType != ''"> and ur.roleType = #{roleAuthorize.roleAuthorizeType} </if> <if test="roleAuthorize.userId != null and roleAuthorize.userId != ''"> and ur.user_id = #{roleAuthorize.userId} </if> </select>
解决方案:
错误的原因在于在Mybatis接口类传入进来的对象不需要xxx对象.xxx属性,如果使用这种就会抛出以下异常,. 直接使用属性名即可。
改成以下就没有问题了:
<!-- 根据角色ID、角色类型、用户ID查询出角色列表--> <select id="getUsersByRoleAuthorize" resultMap="RoleResultMap"> SELECT u.USER_ID, u.user_name, u.user_status, ur.ROLE_ID, r.role_name, ur.ROLE_TYPE, ur.created_by, ur.creation_date, ur.modified_by, ur.modified_date FROM t_user_roles ur,t_user u ,t_roles r WHERE ur.user_id = u.user_id AND r.role_id = ur.role_id <if test="roleAuthorizeId != null and roleAuthorizeId != ''"> and ur.role_id = #{roleAuthorizeId} </if> <if test="roleAuthorizeType != null and roleAuthorizeType != ''"> and ur.roleType = #{roleAuthorizeType} </if> <if test="userId != null and userId != ''"> and ur.user_id = #{userId} </if> </select>
异常信息:
org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:238)
at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:107)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:61)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:56)
at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:118)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:232)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:236)
... 60 more
相关推荐
如果你遇到这样的问题: The entity name must immediately follow the '&' in the entity reference 说明你的& 符号写的有问题
org.apache.http.entity.mime apache的android jar包
Wrox.Professional.ADO.NET.3.5.with.LINQ.and.the.Entity.Framework.Feb.2009.rar
org.apache.http.legacy.jar和org.apache.http.entity.mime4.1.2.jar两个jar包 欢迎下载
Wrox.Professional.ADO.NET.3.5.with.LINQ.and.the.Entity.Framework.Feb.2009
Apress.Pro.Entity.Framework.4.0.Mar.2010.pdf
Z.EntityFramework.Extensions,基于2019年7月,3.21.2.0去除每月验证和强签名。适合.net4.0及以上
Z.EntityFramework.Extensions 破解 注册机,详细破解方法
替换C:\Users\xxxxx\.nuget\packages\z.entityframework.extensions.efcore\2.1.49\lib\netstandard2.0下的Z.EntityFramework.Extensions.EFCore.dll。适用于.net core的ef,解除了1个月使用的限制。
MySql.Data.Entit
Professional.ADO.NET.3.5.with.LINQ.and.the.Entity.Framework(英文PDF)
import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.scheme.Scheme; ...
EF+MySql 数据库操作依赖资源包
这是一个javax.persistence.Entity 的jar包文件。有时候创建JPA工程导入EclipseLink库的时候会缺少这种文件,可以选择在库中加入这个jar包即可
安卓开发类库和jar包httpmime-4.1.2.jar org.apache.http.entity.mime
Z.EntityFramework.Extensions破解,不会用问我
被donet坑了,nuget里更新的dll既然有试用期,有张表数据莫名被删,查时间点,极度怀疑是z.entityframework.extensions的问题,csdn里的太坑,要43个积分,穷人只好找别的地方弄了一个,2个积分拿走不谢
z.entityframework.extensions注册码两个,测试可用!!!!
Manning.Entity.Framework.4.in.Action
Z.EntityFramework.Extensions.dll 破解版,我们在用EF开发时 会有版权报错 要求license,这个dll是我用工具破解的