public void insertTrainer(Trainer trainer){
        //insert entry
        int id = insertNamedEntity(trainer, "TRAINER");
        
        //map its characteristics
//        this.insertIntoTableAllValues(
//                "entity_caracteristic",
//                id,
//                9,//PASSWORD
//                trainer.getPassword()
//        );
        
        /* map his/her pokemons */
        String idChain ="";

        //get the own string => structure like "pokeId(number),pokeId(number),pokeId(number)"...
        ResultSet rs = this.getResultsOfQuery("SELECT * FROM "+megatable+" WHERE typeEntity='TRAINER' AND idC=13 AND valueEntity='"+trainer.getName()+"'" /*13=> OWNED POKEMON*/, true);
        
        //count the results if any
        int rowCount = 0;
        try {
            while (rs.next()) {
                rowCount++;
            }
        } catch (SQLException ex) {
            Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        if (rowCount > 0)
        {
            rs = this.getResultsOfQuery("SELECT * FROM "+megatable+" WHERE typeEntity='TRAINER' AND idC=13 AND valueEntity="+trainer.getName() /*13=> OWNED POKEMON*/, true);
            String owned = extractString(rs, "value");
            HashMap<Integer,Integer> pokemap = new HashMap<>(); 
            for (String id_number : owned.split(","))//id_number structure : pokeId(number)
            {
                int ind = id_number.indexOf("(");
                String poke_id = id_number.substring(0,ind);//pokeId
                String poke_number = id_number.substring(ind);//(number)
                poke_number = poke_number.replaceAll("[^0-9\\.]", "");//number

                pokemap.put(Integer.valueOf(poke_id), Integer.valueOf(poke_number));
            }


            for (Pokemon p : trainer.pool)
            {
                idChain+=p.getId();
                //check existence of the id of p 
                Integer ni = pokemap.get(p.getId());
                if (ni!=null)//if exists => increment
                {
                    ni++;
                }
                else
                {
                    ni = 1;
                }
                idChain+="("+ni+"),";
            }
        }
        else
        {
            for (Pokemon p : trainer.pool)
                idChain+=p.getId()+"(1),";//TODO: add something to count
        }
        
        this.insertIntoTableAllValues("entity_caracteristic",id,13/*OWN*/,idChain);
    }