iBatis和MyBatis 中返回数据对应关系

直接进入主题,现在的项目改用MyBatis了,感觉跟iBatis还是不一样的,比如在判断空值上面,iBatis是有标签的<isNotEmpty><isNotNull>等标签使用,MyBatis确是使用<if></if>来进行这些判断的。所以区别了还是有的,就是看怎么使用方便。不过个人还是觉得MyBatis方便,因为这是面向接口的编程。现在是比较流行的。下面说说我在使用中遇到的问题。

(一):iBatis使用对应关系

iBatis中我们在查询多条数据的时候都会返回一个resultMap,那么我们查询的数据就和resultMap对应,那么有没有想过如果两边对不上会怎么样,特别是在resultMap公用的情况下,你在那边加会有什么影响等情况。

经过我的测试发现,如果查询的字段多了,resultMap对应的字段少了,不会报错,只是查询后后台取的的数据这个字段为NULL值

如果resultMap多了,查询数据的时候没有查询出来这个数据,那么此时就会报错,比如说我查询的时候没有查询name这个字段,但是resultMap里面对应的有这个字段,就会报如下错误

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [S0022]; error code [];
--- The error occurred in com/mouse/snow/pojo/sqlmap/User.xml.
--- The error occurred while applying a result map.
--- Check the Evaluation.get-Evaluation-list.
--- Check the result mapping for the 'name' property.
--- Cause: java.sql.SQLException: Column 'name' not found.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in
com/mouse/snow/pojo/sqlmap/User.xml.
--- The error occurred while applying a result map.
--- Check the Evaluation.get-User-list.
--- Check the result mapping for the 'name' property.
--- Cause: java.sql.SQLException: Column 'name' not found.

这里就说明了,resultMap里面不能多,但是查询的数据是可以多的,只是resultMap里面没有对应,此时pojo里面的数据是空值。

(二):MyBatis的使用

  在我是使用MyBatis的时候,这种对应关系谁多谁少都不会报错的,不影响。我是在使用模糊查询的时候遇到了问题,下面说说模糊查询的方式

(1):模糊查询的方式有好多的,当你传入一个单个数据模糊查询的时候,就是只传入一个keyword时候,传到*.xml里面,我每次都是使用如下

select * from t_user where id like '%${keyword}%'

当时当我这样写的时候出现了错误:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'keyword' in 'class java.lang.String'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:) ~[mybatis-spring-1.2..jar:1.2.]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:) ~[mybatis-spring-1.2..jar:1.2.]
at com.sun.proxy.$Proxy16.selectList(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:) ~[mybatis-spring-1.2..jar:1.2.]
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:) ~[mybatis-3.2..jar:3.2.]
at com.sun.proxy.$Proxy25.selecetStationByWord(Unknown Source) ~[na:na]
at com.xpg.charge.service.impl.ChargingPileServiceImpl.selecetStationByWord(ChargingPileServiceImpl.java:) ~[ChargingPileServiceImpl.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:) ~[na:1.7.0_25]
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor$.proceedWithInvocation(TransactionInterceptor.java:) ~[spring-tx-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:) ~[spring-tx-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:) ~[spring-tx-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:) ~[spring-aop-4.1..RELEASE.jar:4.1..RELEASE]
at com.sun.proxy.$Proxy28.selecetStationByWord(Unknown Source) ~[na:na]
at com.xpg.charge.controller.web.ChargingPileController.selectStationByKeyWord(ChargingPileController.java:) ~[ChargingPileController.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:) ~[na:1.7.0_25]
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:) ~[spring-web-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:) ~[spring-web-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:) ~[spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:) ~[spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:) ~[spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:) ~[spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:) ~[spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:) ~[spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:) [spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:) [spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:) ~[servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:) [spring-webmvc-4.1..RELEASE.jar:4.1..RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:) ~[servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:) ~[tomcat7-websocket.jar:7.0.]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.AbstractShiroFilter$.call(AbstractShiroFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:) ~[shiro-core-1.2..jar:1.2.]
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:) ~[shiro-core-1.2..jar:1.2.]
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:) ~[shiro-core-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[shiro-web-1.2..jar:1.2.]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:) ~[spring-web-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:) ~[spring-web-4.1..RELEASE.jar:4.1..RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:) ~[spring-web-4.1..RELEASE.jar:4.1..RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[spring-web-4.1..RELEASE.jar:4.1..RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:) ~[catalina.jar:7.0.]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:) ~[catalina.jar:7.0.]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:) ~[tomcat-coyote.jar:7.0.]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:) ~[tomcat-coyote.jar:7.0.]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:) ~[tomcat-coyote.jar:7.0.]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:) ~[na:1.7.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:) ~[na:1.7.0_25]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:) ~[tomcat-coyote.jar:7.0.]
at java.lang.Thread.run(Thread.java:) ~[na:1.7.0_25]
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'keyword' in 'class java.lang.String'
at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.TextSqlNode$BindingTokenParser.handleToken(TextSqlNode.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.parsing.GenericTokenParser.parse(GenericTokenParser.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.TextSqlNode.apply(TextSqlNode.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:) ~[mybatis-3.2..jar:3.2.]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:) ~[na:1.7.0_25]
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:) ~[mybatis-3.2..jar:3.2.]
at com.github.pagehelper.SqlUtil._processPage(SqlUtil.java:) ~[pagehelper-4.0..jar:na]
at com.github.pagehelper.SqlUtil.processPage(SqlUtil.java:) ~[pagehelper-4.0..jar:na]
at com.github.pagehelper.PageHelper.intercept(PageHelper.java:) ~[pagehelper-4.0..jar:na]
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:) ~[mybatis-3.2..jar:3.2.]
at com.sun.proxy.$Proxy36.query(Unknown Source) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:) ~[na:1.7.0_25]
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:) ~[mybatis-3.2..jar:3.2.]
at tk.mybatis.mapper.mapperhelper.MapperInterceptor.intercept(MapperInterceptor.java:) ~[mapper-3.1..jar:na]
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:) ~[mybatis-3.2..jar:3.2.]
at com.sun.proxy.$Proxy36.query(Unknown Source) ~[na:na]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:) ~[mybatis-3.2..jar:3.2.]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:) ~[mybatis-3.2..jar:3.2.]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:) ~[na:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) ~[na:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:) ~[na:1.7.0_25]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:) ~[mybatis-spring-1.2..jar:1.2.]
... common frames omitted
.::03.888 DEBUG [http-bio--exec-] org.springframework.beans.factory.support.DefaultListableBeanFactory[] - Returning cached instance of singleton bean 'sqlSessionFactory'

这个bug让我好无奈的感觉,所以我只能改了一种方式

select * from t_user where id like CONCAT('%',#{keyword},'%'),只有这样写才可以,弄得我相当郁闷啊。

我这里传入的值完整如下:

  <select id="selecetUserByWord" resultType="java.lang.String" parameterType="java.lang.String">
select id from t_user where
id like CONCAT('%',#{keyword},'%')
</select>

说明:我这里红色部分是指明了是传入单个参数的,如果你传入的是一个对象,然后'%${keyword}%'的话就可以,比如

 <select id="selecetUserByWord" parameterType="com.mouse.snow.User" resultType="java.lang.String">
select id from t_user where
id like '%${keyword}%'
</select>

我也还没找到具体原因,但是在一些群里让群友实验,他们说他们的可以,所以我也好郁闷,因为我个人认为是可以的,不知道是否是配置问题。

三:MyBatis返回键值对形式

我们都知道我们返回的数据都有个resultType对应,有时候我们都是自己写个对象来接收的,但是其实我们有时候又不用的对象的,可以直接把查询的数据转换为键值对的形式就行返回,这里其实可以百度试验下,

Mapper层:
public List<Map<String,Object>> getUserList(); *.xml层:
<select id="selecetUser" resultType="java.util.HashMap">
select id from t_user
</select>

类似这样就可以把查询的数据转换为键值对形式。多条数据那么就是一个list了,这样还是比较方便的。

还有一点没说,就是查询数据的时候本来就是默认把数据转化为键值对的形式如果有对象,才会再去进一步转换的,所以觉得这样直接键值对的形式得到数据的速度会更加迅速的。

这一点是在这里看见的,http://blog.csdn.net/liubo2012/article/details/8261309。

总结

最近其实学到好多知识点,比如阿里云的跨域上传下载等。一些开源的知识等,希望自己每天都能抽出点时间来写点东西,昨天去了一趟香港买了电脑,mac pro,要还几个月的款子啊,努力上班的,boy

Ibatis的resultMap和查询数据的对应关系的更多相关文章

  1. Mybatis查询,resultMap="Map" 查询数据有空值,导致整个map为空的问题

    解决方法,不要使用Map接收,使用HashMap或者LinkHashMap,都可以. resultMap="Map" 替换为: resultMap="HashMap&qu ...

  2. 在使用Ibatis查询数据返回时,报如下错误:java ibatis The error happened while setting a property on the result object

    问题: 在使用Ibatis查询数据返回时,报如下错误: [com.show.add.proxy.SqlMapClientTemplateProxy]com.ibatis.common.jdbc.exc ...

  3. 在MyBatis中查询数据、涉及多参数的数据访问操作、插入数据时获取数据自增长的id、关联表查询操作、动态SQL、关于配置MyBatis映射没有代码提示的解决方案

    1. 单元测试 在单元测试中,每个测试方法都需要执行相同的前置代码和后置代码,则可以自定义2个方法,分别在这2个方法中执行前置代码和后置代码,并为这2个方法添加@Before和@After注解,然后, ...

  4. Ibatis组合键关联查询

    在使用Ibatis时,会经常遇到关联查询,一般有两种解决方案: 使用代码进行关联查询 使用Ibatis配置文件进行关联查询 使用代码进行关联查询不作解释,本次主要是针对Ibatis配置文件进行关联查询 ...

  5. ibatis 参数之模糊查询

    因项目需要最近使用ibatis,在使用查询语句的时候,想着通用性所以没有在配置文件里用N多的and 语句,而是如下: <select id="getUsersList" re ...

  6. MyBatis 传入List集合作为条件查询数据

    使用的是SSM框架,数据库是MySQL,做查询的时候传入List集合,使用SQL语句的in方式查询数据 主要有两点问题:我的List集合是利用的另外一个语句查询出来的,传入参数是int类型,返回值是i ...

  7. Mybatis 传入多个参数查询数据 (3种方法)

    第一种方案 DAO层的函数方法 public User selectUser(String name,String area); 对应的Mapper.xml <select id="s ...

  8. 用struts2标签如何从数据库获取数据并在查询页面显示。最近做一个小项目,需要用到struts2标签从数据库查询数据,并且用迭代器iterator标签在查询页面显示,可是一开始,怎么也获取不到数据,想了许久,最后发现,是自己少定义了一个变量,也就是var变量。

    最近做一个小项目,需要用到struts2标签从数据库查询数据,并且用迭代器iterator标签在查询页面显示,可是一开始,怎么也获取不到数据,想了许久,最后发现,是自己少定义了一个变量,也就是var变 ...

  9. Web jquery表格组件 JQGrid 的使用 - 7.查询数据、编辑数据、删除数据

    系列索引 Web jquery表格组件 JQGrid 的使用 - 从入门到精通 开篇及索引 Web jquery表格组件 JQGrid 的使用 - 4.JQGrid参数.ColModel API.事件 ...

随机推荐

  1. text-align与vertical-align属性的区别

    1.text-align属性设置元素在水平方向(x轴)的位置 text-align:left://文本居左 text-align:center://文本居中 text-align:right: //文 ...

  2. Python中用字符串导入module

    在Python中,无法通过字符串来导入一个module文件: import "string" # Error x = "string" import x # 不 ...

  3. CF刷刷水题找自信1

    CF 1108A Two distinct points 题目意思:给你两个线段的起点和终点,让你给出两个不同的点,这两点分别处于两个不同的线段之中.解题思路:题目说如果存在多种可能的点,随意一组答案 ...

  4. “我爱淘”第二冲刺阶段Scrum站立会议6

    完成任务: 完成学院分类的点击查看书籍功能,可以点击书的条目查看书的详细信息. 计划任务: 将书的详细信息进行完善,并且可以点击收藏以及已预订等功能. 遇到问题: 分类功能,根据不同学院,自动将数据库 ...

  5. iOS- Autolayout自动布局

    1.前言 •在iOS程序中,大部分视图控制器都包含了大量的代码用于设置UI布局,设置控件的水平或垂直位置,以确保组件在不同版本的iOS中都能得到合理的布局 •甚至有些程序员希望在不同的设备使用相同的视 ...

  6. QMdiArea及QMdiSubWindow实现父子窗口及布局方法

    版权声明:若无来源注明,Techie亮博客文章均为原创. 转载请以链接形式标明本文标题和地址: 本文标题:QMdiArea及QMdiSubWindow实现父子窗口及布局方法     本文地址:http ...

  7. 性能测试工具Loadrunner使用经验小结(原创更新版)

    1. 引言 1.1. 简介 loadrunner是一种预测系统行为和性能的负载测试工具,它可以轻松创建虚拟用户.创建真实的负载.定位性能问题.重复测试保证系统的高性能 globa-100的注册码:AE ...

  8. p2 休眠模式

    如有错误,忘请指出. 才入手p2.p2有全局休眠模式,和钢体体眠模式.钢体能控制 body.allowSleep world.NO_SLEEPING 不允许休眠world.BODY_SLEEPING ...

  9. 【数据库】mysql中复制表结构的方法小结

    mysql中用命令行复制表结构的方法主要有一下几种: 1.只复制表结构到新表 ? 1 CREATE TABLE 新表 SELECT * FROM 旧表 WHERE 1=2 或者 ? 1 CREATE ...

  10. (转)maven下载jar包速度慢(解决办法)

    本文转载至http://blog.csdn.net/ko289830707/article/details/53559052 现在maven项目非常流行,因为它对jar实行了一个非常方便的管理,我们可 ...