list = this.getHibernateTemplate()
.executeFind(new ContabilitaHibernateBindCallback(q.toString(), criteria));
} catch (DataAccessException e) {
log("Impossibile leggere numero protocollo " + e);
e.printStackTrace();
throw new ImpossibileLeggereNumeroProtocolloException();
}
if (list != null && list.size() > 0) {
for (int r = 0; r < list.size(); r++) {
Object o;
o = (Object) list.get(r);
BigDecimal grup = (BigDecimal) o;
if (grup != null)
numeroProtocollo = new Long(grup.longValue());
}
}
if (numeroProtocollo == null) {
q = new StringBuffer();
criteria = new ArrayList<SearchCriteria>();
criteria.add(new SearchCriteria("tipoBollato", tipoBollato));
criteria.add(new SearchCriteria("legalEntity", legalEntity));
criteria.add(new SearchCriteria("organizationUnit", organizationUnit));
q.append(" SELECT DISTINCT TAB_TIPI_PROTOCOLLO.CG14_NR_PROT_INIZIO_ANNO as numeroProtocollo ");
q.append(" FROM CAUS_OPER, ");
q.append(" DET_CAUS_OPER , ");
q.append(" TAB_TIPI_PROTOCOLLO ");
q.append(" WHERE CAUS_OPER.CG02_COD_CAUS_OPER = DET_CAUS_OPER.CG07_COD_CAUS_OPER ");
q.append(" AND DET_CAUS_OPER.CG07_TP_BOLLATO_IVA = TAB_TIPI_PROTOCOLLO.CG14_TP_BOLLATO_IVA ");
q.append(" AND DET_CAUS_OPER.CG07_COD_TP_PROTOCOLLO = TAB_TIPI_PROTOCOLLO.CG14_COD_TP_PROTOCOLLO ");
q.append(" AND TAB_TIPI_PROTOCOLLO.CG14_TP_BOLLATO_IVA = :tipoBollato ");
q.append(" AND CAUS_OPER.CG02_LEGAL_ENTITY = :legalEntity ");
q.append(" AND CAUS_OPER.CG02_ORG_UNIT = :organizationUnit ");
q.append(" AND CAUS_OPER.CG02_LEGAL_ENTITY = DET_CAUS_OPER.CG07_LEGAL_ENTITY ");
q.append(" AND CAUS_OPER.CG02_ORG_UNIT = DET_CAUS_OPER.CG07_ORG_UNIT ");
q.append(" AND CAUS_OPER.CG02_LEGAL_ENTITY = DET_CAUS_OPER.CG07_LEGAL_ENTITY ");
q.append(" AND CAUS_OPER.CG02_ORG_UNIT = DET_CAUS_OPER.CG07_ORG_UNIT ");
try {
list = this.getHibernateTemplate().executeFind(
new ContabilitaHibernateBindCallback(q.toString(), criteria));
} catch (DataAccessException e) {
log("Impossibile leggere numero protocollo " + e);
e.printStackTrace();
throw new ImpossibileLeggereNumeroProtocolloException();
}
if (list != null && list.size() > 0) {
for (int r = 0; r < list.size(); r++) {
Object o;
o = (Object) list.get(r);