From: Kal A. <ka...@te...> - 2005-12-27 16:04:03
|
Hi George, That sounds strange - the save code by itself should always be doing its work in its own transaction, if the provider has no open transaction, as = you can see in the code you copied in your message. I wonder if there is = some other call which is starting a transaction and failing to close it (it = might be in your code, or in the TM4J persistence layer). To track this down, perhaps you can insert logging statements in various places in your code = - especially at request start and end - to see if the provider has an open transaction or not. I'm guessing that you are holding the TopicMap = object between requests ? The work-around for this might be to wrap all of your operations for a single request in one or more transactions (i.e. use the = openTransaction() and commit() methods explicitly). Cheers, Kal > -----Original Message----- > From: tm4...@li... [mailto:tm4j-users- > ad...@li...] On Behalf Of George Tryfon > Sent: 26 December 2005 13:59 > To: tm4...@li... > Subject: [TM4J-users] Hibernate Transactions question >=20 > Hello, > I am developing a TMAPI server using SOAP web services > the server uses Hibernate and MySQL. >=20 > When I create a new TopicMap, the save function inside the > "org.tm4j.topicmap.hibernate.TopicMapFactoryImpl" > finds that the transaction is closed, opens a new one and saves the > changes > in the database. >=20 > the next time I open the TopicMap, again the transaction is closed, = and > the > function does the > same thing, and saves the changes. >=20 > The third time? > Something strange is happening here from the third time and after. > the transaction found open, the change happens but not saved inside = the > database. > I suppose because there is no commit() > When I close the server and I start it again, all the changes without = the > commit() are gone! > I didn't have this problem when I tried to do the same thing using RMI > server and Hibernate > (I am using SOAP now) >=20 > There is more than a week now where I am puzled with this and any = hint, > idea, anything, would be highly appreciated >=20 > could be a good idea to force closing the transaction, or commit? >=20 > Thank you in advance. > Cheers >=20 >=20 > protected void save(PersistenceWrapper tmobject, String id) throws > DuplicateObjectIDException > { > if (id =3D=3D null) > { > id =3D m_idgen.getID(); > } >=20 > try > { > TopicMapObjectDataObject dataObject =3D = ((TopicMapObjectDataObject) > tmobject.m_dataObject); >=20 > if (m_provider.isTransactionOpen()) > { > System.out.println ("transaction is open"); > checkID(m_provider.getOpenTransaction(), id); > dataObject.setObjectId(id); >=20 > TopicMapDataObject tmdo =3D (TopicMapDataObject) > PersistenceWrapper.load(m_provider.getOpenTransaction(),m_topicMap); > dataObject.setTopicMap(tmdo); > PersistenceWrapper.persist(m_provider.getOpenTransaction(), > tmobject); > } > else > { > System.out.println ("transaction is closed"); > ProviderTransaction txn =3D m_provider.openTransaction(); >=20 > try > { > checkID(m_provider.getOpenTransaction(), id); > dataObject.setObjectId(id); >=20 > TopicMapDataObject tmdo =3D (TopicMapDataObject) > PersistenceWrapper.load(txn,m_topicMap); > dataObject.setTopicMap(tmdo); > PersistenceWrapper.persist(txn, tmobject); > txn.commit(); > } > catch (Exception ex) > { > txn.rollback(); > throw ex; > } > } >=20 > if (tmobject instanceof TopicImpl) > { >=20 > m_provider.registerTopic(tmobject.getPersistenceId(),(TopicImpl) > tmobject); > } > } > catch (DuplicateObjectIDException ex) > { > throw ex; > } > catch (Exception ex) > { > throw new TopicMapRuntimeException("Storage Exception.", ex); > } > } >=20 >=20 > ____________________________________________________________________ > http://www.freemail.gr - =E4=F9=F1=E5=DC=ED =F5=F0=E7=F1=E5=F3=DF=E1 = =E7=EB=E5=EA=F4=F1=EF=ED=E9=EA=EF=FD = =F4=E1=F7=F5=E4=F1=EF=EC=E5=DF=EF=F5. > http://www.freemail.gr - free email service for the Greek-speaking. >=20 >=20 > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD = SPLUNK! > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick > _______________________________________________ > Tm4j-users mailing list > Tm4...@li... > https://lists.sourceforge.net/lists/listinfo/tm4j-users >=20 |