-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate verwurschtelt Objekte
PostPosted: Thu Feb 21, 2008 11:43 am 
Newbie

Joined: Fri Jan 25, 2008 9:07 am
Posts: 5
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?


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

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.