mysql - executeUpdate() hibernate and spring return to controller number of rows -


i have problem return affected rows in springmvc/hibernate project(mysql databse).

this dao file, must return size of affected rows in database. when execute method in controller file have "null". maybe problem threads of hibernate , spring? must have row in spring controller. help, if u can. see below:

@transactional public integer addstudenci(string imie, string nazwisko, string nrindeksu,         string email, integer rok, integer semestr, string przedmiot,         string login, string haslo) {      session session = sessionfactory.opensession();     transaction tx = session.begintransaction();     string query = "insert ignore studenci(imiona,nazwisko,nr_indeksu, email, rok, semestr, przedmiot_krztalcenia, login, haslo) values(:imie,:nazwisko,:nrindeksu,:email,:rok,:semestr,:przedmiot,:login,:haslo)";      integer addint=-1;     addint= sessionfactory.getcurrentsession().createsqlquery(query)             .setparameter("imie", imie).setparameter("nazwisko", nazwisko)             .setparameter("nrindeksu", nrindeksu)             .setparameter("email", email).setparameter("rok", rok)             .setparameter("semestr", semestr)             .setparameter("przedmiot", przedmiot)             .setparameter("login", login).setparameter("haslo", haslo)             .executeupdate();       tx.commit();     session.close();      return addint; } 

my service file method:

@transactional     public integer addstudenci(string imie, string nazwisko, string nrindeksu,             string email, integer rok, integer semestr, string przedmiot,             string login, string haslo) {         return logindao.addstudenci(imie, nazwisko, nrindeksu, email, rok, semestr,                 przedmiot, login, haslo);     } 

this simple code reading number of rows(using method service)

integer addnumber = -1; addnumber = loginservice.addstudenci(name_student, nazwisko_student, nrind_student, email, roki, semestri, przedmiot_ksztalcenia, login, haslo); system.console().writer().println(addnumber); if(1 == addnumber) { string temat = "przesłanie hasła logowania!"; try{ sendmail.wyslij_maila(email, temat, haslosend, "system zarządzania projektami na pwr"); } catch(exception ex) { ; }  } else { nrind_student = fields1; } 

and must know in controller number of records(from query).

any idea?


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -