hibernate - Request return wrong data -


i'm project in use ninjaframework api (no-rest api). insert data database through request style:

@transactional public result askcita(context context, datacitasask cita) {      manager.gettransaction().begin();     manager.persist(cita);     manager.gettransaction().commit(); } 

and when collect data database through request this; not return same data. not return last data inserted.

@transactional public result listcitas(context context, datacitaslist cita) {      if (cita == null) {         return results.json().render(false);     }      // la ip del cliente     string ipclient = context.getremoteaddr();      entitymanager entitymanager = provider.get();     dbcitas db = dbcitas.getinstance();      datacitaslistresult vuser = db.listcitas(entitymanager, cita);      return results.json().render(vuser); }  public datacitaslistresult listcitas(entitymanager manager,         datacitaslist data) {     string ucheck = cita.query_clinic_month;      calendar calbefore = calendar.getinstance();     calendar calafter = calendar.getinstance();     calafter.set(calendar.month, calafter.get(calendar.month) + 1);      databasecontroller db = databasecontroller.getinstance(manager);     query q = db.getquery(ucheck);     q.setparameter("datebegan", calbefore.gettime());     q.setparameter("dateend", calafter.gettime());     q.setparameter("idclinic", data.getidclinic());      list<cita> list = q.getresultlist();      dbvetdata vdata = dbvetdata.getinstance();     vetdata clinic = vdata.getclinicdb(manager, data.getidclinic());      datacitaslistresult rdata = new datacitaslistresult();     rdata.setclinica(clinic);     rdata.setcitas(new arraylist<datacitasresultitem>());      if (list.isempty()) {         return rdata;     }      arraylist<datacitasresultitem> lcitas = new arraylist<datacitasresultitem>();     (cita cita : list) {         datacitasresultitem ncita = new datacitasresultitem();         ncita.setanswered(cita.getdatevet() != null ? true : false);         ncita.setcreated(spf.format(cita.getcreated().gettime()));         if (cita.getdatecita() != null) {             ncita.setdatecita(spf.format(cita.getdatecita().gettime()));         }         if (cita.getdatevet() != null) {             ncita.setdatevet(spf.format(cita.getdatevet().gettime()));         }         ncita.setid(cita.getid());         ncita.setidmascota(cita.getpet().getid());         ncita.setnamemascota(cita.getpet().getname());         ncita.setmotivo(cita.getmotive());         ncita.settipocita(cita.gettype().getid());          //         lcitas.add(ncita);     }     rdata.setcitas(lcitas);      return rdata; } 

in database if appear; seems little more consultation, insertion.

i not understand why.

pd: include citas.class definition:

@entity(name = "citas")    @table(name = "citas")    public class cita {       @id     @generatedvalue(strategy = generationtype.auto)     private long id;      @column(name = "created")     private timestamp created;      @manytoone     @joincolumn(name = "id_mascota")     private pet pet;      @column(name = "date_cita")     private calendar datecita;     @column(name = "date_vet")     private calendar datevet;     @column(name = "motivo")     private string motive;     @column(name = "sended")     private long sended;      @manytoone     @joincolumn(name = "tipo_cita")     private citatype type;      @manytoone     @joincolumn(name = "id_clinica")     private vetdata clinica;      } 


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -