Hello all,
i have quite a strange problem on updating data.
If i do an update (code below) for a few times, then there are the values of the all objects of apparenty randomly mixed together.
heres the update method:
Code:
public void activateStudie(int pkStudienID)
{
Session session = HibernateSessionFactory.currentSession(); //hol die Session
Transaction tx = session.beginTransaction(); //beginne mit der Transaktion - ab hier Datenmanipulation
Studien studie = (Studien) session.get(Studien.class, pkStudienID); //get the Studie(pkID)
studie.setActive(1);
ms_logStudienManager.info("Aktivate StudieID: " + pkStudienID + " Active: " + studie.getActive() + " Studienkurztext: " + studie.getKurztext() );
session.flush();
tx.commit();
}
Following code gets the list of all Studies in database.
Code:
public Studien[] getAllStudies()
{
ms_logStudienManager.info("Getting and return all studies as an Studien[] - Array");
List<Studien> alStudien = new ArrayList<Studien>(); /* will hold the studien we are going to return later */
Session session = null; // a Hibernate session - SingleTon Pattern --> global static method
Transaction tx = null; /* we always need a transaction */
session = HibernateSessionFactory.currentSession(); //hol die Session
tx = session.beginTransaction(); //beginne mit der Transaktion - ab hier Datenmanipulation
List tmpStudie = session.createQuery("from Studien").list();
for (Iterator iter = tmpStudie.iterator(); iter.hasNext();) {
Studien studie = (Studien) iter.next();
ms_logStudienManager.info("Studiennummer: " + studie.getInternalid() + " Active: " + studie.getActive() + " Kurztext: " + studie.getKurztext());
alStudien.add(studie);
}
session.flush();
tx.commit();
return (Studien[]) alStudien.toArray(new Studien[0]);
}
Hope somebody can help me.
Is it a caching problem?