Hi,
I am facing yet another problem, this time performing a simple mail merge.
There problem is, the resulting document after the mail merge operation contains some fields which seem to have been replaced by the java “object ID” or something similar, instead of the actual value.
I have attached both my template.doc and result.doc.
The problem seems to be happening for three fields named massima_quantita_deposito, periodicita_carico and periodicita_scarico.
All the data is taken from a MySQL 5.1 database through this query:
SELECT t1.*, IFNULL(t1.rifiuto, ‘===’) as rifiuto,
IFNULL(t1.destino, ‘===’) as destino,
IFNULL(t1.rifiuto, ‘===’) as rifiuto,
IFNULL(t1.stato_fisico, ‘===’) as stato_fisico,
IFNULL(t1.nome_responsabile, ‘===’) as nome_responsabile,
IFNULL(t1.descrizione, ‘===’) as descrizione,
IFNULL(t1.materie_prime, ‘===’) as materie_prime,
IFNULL(t1.contenitore, ‘===’) as contenitore,
IFNULL(t1.deposito, ‘===’) as deposito,
IF(t1.data_ultima_analisi IS NULL, ‘===’, DATE_FORMAT(t1.data_ultima_analisi, ‘%d-%m-%Y’)) as data_ultima_analisi,
IF(t1.quantita_deposito > 0, CONCAT(t1.quantita_deposito, ’ ', t1.unita_misura), ‘===’) as massima_quantita_deposito,
IF(t1.carico_periodicita_num > 0, CONCAT('ogni ', t1.carico_periodicita_num, ’ ', get_periodicita_tipo(t1.carico_periodicita_tipo)), ‘===’) as periodicita_carico,
IF(t1.scarico_periodicita_num > 0, CONCAT('ogni ', t1.scarico_periodicita_num, ’ ', get_periodicita_tipo(t1.scarico_periodicita_tipo)), ‘===’) as periodicita_scarico,
t2.codice as codice_cer,
t2.descrizione as descrizione_cer,
IF(t1.destino = ‘Smaltimento’, CONCAT(t4.smaltimento, ’ - ', t4.codice),
IF(t1.destino = ‘Recupero’, CONCAT(t3.recupero, ’ - ', t3.codice), ‘===’)) as destino_operazione,
IFNULL(GROUP_CONCAT(DISTINCT CONCAT(t6.codice, ’ - ', t6.pericolo) ORDER BY t6.pericolo SEPARATOR ‘\n’), ‘===’) as classi_pericolo,
IFNULL(GROUP_CONCAT(DISTINCT t8.nome_area_lavoro ORDER BY t8.nome_area_lavoro SEPARATOR ‘\n’), ‘===’) as processi
FROM lin_98_47_rifiuti as t1
JOIN agews_rifiuti_cer as t2 USING(id_codice)
LEFT JOIN agews_rifiuti_recupero as t3 USING(id_recupero)
LEFT JOIN agews_rifiuti_smaltimento as t4 USING(id_smaltimento)
LEFT JOIN lin_98_47_pericolo as t5 USING(id_rifiuto, id_azienda, id_sede, revisione_documento)
LEFT JOIN agews_rifiuti_pericolo as t6 USING(id_pericolo)
LEFT JOIN lin_98_47_processi as t7 USING(id_rifiuto, id_azienda, id_sede, revisione_documento)
LEFT JOIN gen_12_1_aree_lavoro as t8 USING(id_area_lavoro, id_azienda, id_sede, revisione_documento)
WHERE id_rifiuto = ‘2’ AND id_azienda = ‘3’ AND id_sede = ‘12’ AND revisione_documento = '0’
GROUP BY id_rifiuto
The data returned by the query, together with the table structure, is inside the attached .xml file.
The mailmerge is then done by calling
doc.getMailMerge().execute(new DataTable(rs));
where doc is the Document and rs is the corresponding ResultSet.
Why am I getting such a strange merge? And how can I solve this problem?
By the way, this is just an example, I have similar problem on other templates as well!