MyBatis - storage of several types

Before you begin, here is the structure of my classes

  • Personne

    • PersonnePhysique (extend Personne)

    • PersonneMorale (renewing Personne)

      • Entreprise (extend PersonneMorale)
      • Association (renewal PersonneMorale)

I am trying to insert "Personne" into the database and I need to check if it is "PersonnePhysique", "Entreprise" or "Association". So, I did this in my cartographer:

<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> 

But none of these tests pass. What am I doing wrong?

+4
source share
1 answer

I found a solution, although not in an official document, that should not be a problem for future versions: if test = "_ parameter instanceof fr.maaf.personne.Entreprise"

+3
source

All Articles