types - MyBatis - 持有多种类型

标签 types insert mybatis

在开始之前,这是我的类的结构

  • 人事
  • PersonnePhysique(扩展Personne)
  • PersonneMorale(扩展人员)
  • 企业(扩展 PersonneMorale)
  • 协会(扩展 PersonneMorale)

  • 我试图在数据库中插入一个“Personne”,我需要检查它是“PersonnePhysique”、“Entreprise”还是“Association”。
    所以,我在我的映射器中做了这个:
    <insert id="creerPersonne" parameterType="Personne">
       ....
    
    <choose>
        <when test="getClass() instanceof fr.maaf.personne.PersonnePhysique">
            1, 
        </when>
        <when test="getClass() instanceof fr.maaf.personne.Association">
            2, 
        </when>
        <when test="getClass() instanceof fr.maaf.personne.Entreprise">
            2, 
        </when>
    </choose>
    
      ...
    </insert>
    

    但是这个测试都没有通过。
    我究竟做错了什么 ?

    最佳答案

    我找到了一个解决方案,尽管不在官方文档中,但对于 future 的版本不应该是问题:if test="_parameter instanceof fr.maaf.personne.Entreprise"

    关于types - MyBatis - 持有多种类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14477142/

    相关文章:

    go - Go 中的函数类型 - 将特定类型转换为更通用的类型

    mysql - 从 TableB 插入到 TableA,其中 FieldX 值尚不存在

    java - 是否可以使用带注释的绑定(bind)?

    java - mybatis 映射器使用相同参数跨多个列进行搜索

    java - MySQL 插入 Gson 日期

    postgresql - 在 plpgsql 的 FOR 循环中使用自定义返回类型

    go - Go 如何确定可以使用多个值的上下文?

    javascript - AngularJS - 类型错误 : Cannot read property 'go' of undefined

    php - 用mysql将多行插入数据库

    sql - 为从选择中获取的每一行执行插入?