English 中文(简体)
在MyBatis建立一栏建筑关系
原标题:Get column-property mapping relationship in MyBatis
  • 时间:2012-01-12 07:00:13
  •  标签:
  • mybatis

我需要在MyBatis进行一些动态的地图绘制,以便每个栏目在下面做一些事情:

switch (filter.FilterType)
        {
            case FilterType.BeginsWith:
                operatorStr = "UPPER({0}) LIKE  {1}%  ";
                value = filter.Value.ToUpper();
                break;
            case FilterType.Contains:
                operatorStr = "UPPER({0}) LIKE  %{1}%  ";
                value = filter.Value.ToUpper();
                break;
            case FilterType.GreaterThan:
                operatorStr = " {0} > {1} ";
                break;
            case FilterType.GreaterThanOrEqual:
                operatorStr = " {0} >= {1} ";
                break;
            case FilterType.LessThan:
                operatorStr = " {0} < {1} ";
                break;
            case FilterType.LessThanOrEqual:
                operatorStr = " {0} <= {1} ";
                break;
        }

我之所以需要这样的过滤器,是因为我有一个网页,显示表格数据为网格,每个栏目都可以检索/浏览。 我不想写一下每栏中哪一个条款,这样,我就想看到,Mybatis一栏建筑图案是否有助于这项工作。

我要让米巴特西人知道我想要哪一栏能够证明在过滤中是有效的。 我知道,我可以采用简单的动态方法,在我自己的习俗法典中生动地表明这一点,而我实际上想要打上一栏。 但我不想混淆方案拟订来源代码中的实际表格栏目。 我认为,这样做更明智的做法是将阶级财产名称传入Mybatis的AP,然后,让它标明标明该类财产名称的实际一栏。

是否有任何人想如何这样做? 在Mybatis,是否有一份标书来提供这一一栏-property的制图关系功能,例如,它可能像一个字典,我以财产名称通过该词,然后给我实际的一栏名称?

提前感谢!

问题回答

交换台没有得到我的施压人的支持,因此,你可以用来实现这一目标。

<choose>
            <when test=""></when>
            <when test=""></when>
            <when test=""></when>
            <when test=""></when>
            <otherwise></otherwise>
        </choose>

u可以通过过滤器作为参数,然后加以核实。





相关问题
MyBatis: Sybase stored procedure returns zero rows

I have copied the text from here: http://code.google.com/p/mybatis/issues/detail?id=164, but we faced the same issue. MyBatis version 3.0.1 I use MyBatis 3 as the OR mapping between the java ...

Return a Single Map in IBATIS

I have a SqlMap query that returns 2 columns, an ID and a string. I know how to return a list of maps where the ID is the key and the string is the value. There is one list item for each row ...

How to add multiple named parameters to the SQL statement?

I would like to write something like this in myBatis (using anotations instead of XML): @Insert("INSERT INTO friendships (user_id, friend_id) VALUES (#{user.id}, {friend.id})") public void insert(...

Spring declarative transaction management not working

I am using spring 3.0.3.RELEASE along with mybatis-3.0.2 and mybatis-spring-1.0.0 running in Apache Tomcat 6.0.29 with JDK 1.6.0_21. I created my DAO class and Service class and defined following ...

How do I insert collection of objects using MyBatis 3.x?

I m a beginner with MyBatis. I just want to know how to insert a collection of objects from an instance of a class. Say I have a class User related to a Note in one-to-many relationship. I just like ...

热门标签