在开始之前,这是我的类的结构
我试图在数据库中插入一个“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/