sotto ti ho copiato la classe che utilizzo come riferimento per il passaggio di dati. Solo che credo non sia la classe di per se il problema ma bensi il fatto che il mio metodo cerca di inviarmi un List di questo ogggetto. Quindi non so se devo cche devo fare sinceramente.
questa è la classe che utlizzo per passare i dati:
codice:
package dto;
import java.io.Serializable;
public class UtenteDTO implements Serializable{
/** * */ private static final long serialVersionUID=2668829823212145195L;
private int idUtente;
private String nome;
private String cognome;
private String eta;
private String indirizzo;
public int getIdUtente() {
return idUtente;
}
public void setIdUtente(int idUtente) {
this.idUtente = idUtente;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getCognome() {
return cognome;
}
public void setCognome(String cognome) {
this.cognome = cognome;
}
public String getEta() {
return eta;
}
public void setEta(String eta) {
this.eta = eta;
}
public String getIndirizzo() {
return indirizzo;
}
public void setIndirizzo(String indirizzo) {
this.indirizzo = indirizzo;
}
}
invece il metodo con cui cerco di farmi passare un List è:
codice:
public List ricercaUtenti(UtenteDTO utente){
List risultatoRicercaUtenti = new ArrayList();
UtenteDTO ute = null;
boolean valorizzazioneCampo = false;
String sql = "select * from test.servizi where ";
if(utente.getNome() != null){
valorizzazioneCampo = true;
sql = sql + "nome = ?";
}
if(utente.getCognome() != null){
if(valorizzazioneCampo){
sql = sql + " and cognome = ?";
}else{
valorizzazioneCampo = true;
sql = sql + " cognome = ?";
}
}
if(utente.getEta() != null){
if(valorizzazioneCampo){
sql = sql + " and eta = ?";
}else{
valorizzazioneCampo = true;
sql = sql + " eta = ?";
}
}
if(utente.getIndirizzo() != null){
if(valorizzazioneCampo){
sql = sql + " and indirizzo = ?";
}else{
valorizzazioneCampo = true;
sql = sql + " indirizzo = ?";
}
}
try {
ps = conn.prepareStatement(sql);
if(utente.getNome() != null){
ps.setString(1, utente.getNome());
}
if(utente.getCognome() != null){
ps.setString(2, utente.getCognome());
}
if(utente.getEta() != null){
ps.setString(3, utente.getEta());
}
if(utente.getIndirizzo() != null){
ps.setString(4, utente.getIndirizzo());
}
System.out.println(sql);
ResultSet rs = ps.executeQuery();
while(rs.next()){
ute = new UtenteDTO();
ute.setIdUtente(rs.getInt(2));
ute.setNome(rs.getString(3));
ute.setCognome(rs.getString(4));
ute.setEta(rs.getString(5));
ute.setIndirizzo(rs.getString(6));
risultatoRicercaUtenti.add(ute);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Call call = (Call) new Service().createCall();
call.registerTypeMapping(List.class, new
QName("myNS:UtenteDTO"),BeanSerializerFactory.class,
BeanDeserializerFactory.class);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return risultatoRicercaUtenti;
}