-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Cannot update two table fields
PostPosted: Thu Nov 27, 2008 1:10 pm 
Newbie

Joined: Fri Sep 12, 2008 7:31 am
Posts: 1
Hello everyone i got a problem with hibernate update statement, below i am updating two table fields but when i execute a code, it updates the field of the first table and doesnot update the second.



Code:
String doktorTetkikUpdate = "UPDATE TblHastaTetkikHareket hastatetkik " +
          "SET hastatetkik.hrkTetkikDoktor = " +iMap.getLong("ICHASTNO")+" "+
          "WHERE hastatetkik.id.hrkProtno = :hno " +
          "and hastatetkik.id.hrkTekrar = :tekrar " +
          "and hastatetkik.id.hrkTetkikYili = :tyil " +
          "and hastatetkik.hrkTetkikDoktor =:dno " +
         "and hastatetkik.id.hrkBirim = :bno ";
Query qDTU = sessionHasta.createQuery(doktorTetkikUpdate);
qDTU.setParameter("hno",iMap.getLong("HASTANO"));
qDTU.setParameter("tekrar",iMap.getInt("TEKRAR"));
qDTU.setParameter("tyil",hyil);
qDTU.setParameter("dno",iMap.getLong("ICHASTNO_ESKI");
qDTU.setParameter("bno",iMap.getInt("BIRIMNO"));
qDTU.executeUpdate();
sessionHasta.flush();

String doktorSaglikUpdate = "UPDATE TblSaglikKurulHrk saglik " +
   "SET saglik.sagMIcHas = "+iMap.getString("ICHASTNO")+" "+
    "WHERE saglik.id.sagRaporNo = :rno "+
   "and saglik.id.sagTarih = :rtarih " +
   "and saglik.sagProtno = :hno " +
   "and saglik.sagTekrar = :tekrar ";
Query qDSU = sessionHasta.createQuery(doktorSaglikUpdate);
qDSU.setParameter("rno",iMap.getInt("RAPORNO"));
qDSU.setParameter("rtarih",iMap.getDate("RAPORTARIHI"));
qDSU.setParameter("hno",iMap.getLong("HASTANO"));
qDSU.setParameter("tekrar",iMap.getInt("TEKRAR"));
qDSU.executeUpdate();
sessionHasta.flush();

i dont get any exceptions or errors
I use jdk 1.6 and hibernate 3.0 version
if anyone got the same problem and a got a solution plz help me


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2008 9:40 am 
Beginner
Beginner

Joined: Wed Nov 19, 2008 6:39 am
Posts: 44
Location: Mumbai, India
You didn't commit the transaction.Commit the transaction before session flush.
tx.commit();
sessionHasta.flush();

do this after exexute the query.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.