From: George T. <geo...@fr...> - 2005-12-27 21:59:03
|
I found this for the Hibernate Transaction. The transaction remain open after I call a Tolog query (bypassing the TMAPI) public String[] getRemoteTologTmos (String tmName, String query, String= =20 colonName) throws RemoteException { try { TopicMap _tm =3D TMHelper.getDefault().getTopicMap(tmName); org.tm4j.topicmap.TopicMap tm =3D Wrapper.unwrap(_tm);=20 //_tm.getWrapped()); QueryEvaluator qe =3D QueryEvaluatorFactory.newQueryEvaluator (tm); //TODO: add rules here... //qe.addRule ("t($T) :- topic($T)."); org.tm4j.topicmap.TopicMapProvider provider =3D tm.getProvider (); ProviderTransaction providerTransaction =3D=20 provider.getOpenTransaction(); if (providerTransaction =3D=3D null) providerTransaction =3D provider.openTransaction(); System.out.println (query); //<> TologResultsSet rSet =3D qe.execute (query); System.out.println ("execution done."); //<> int colonIndex =3D -1; for (int c=3D0; c<rSet.getNumCols(); c++) { if (rSet.getVar(c).equals(colonName)) colonIndex =3D c; } Vector<String> v =3D new Vector<String> (); for (int i=3D0; i<rSet.getNumRows(); i++) { List list =3D rSet.getRow (i); org.tm4j.topicmap.TopicMapObject tmo =3D=20 (org.tm4j.topicmap.TopicMapObject)list.get (colonIndex); v.add (tmo.getID()); } return v.toArray(new String[0]); } catch (Exception ex) { throw new RemoteException (ex.getMessage(), ex); } } what is your suggestion in order to close the transaction? Cheers, George ----- Original Message -----=20 From: "Kal Ahmed" <ka...@te...> To: "'George Tryfon'" <geo...@fr...>;=20 <tm4...@li...> Sent: Tuesday, December 27, 2005 5:30 PM Subject: RE: [TM4J-users] Hibernate Transactions question 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 mi= ght 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 > > Hello, > I am developing a TMAPI server using SOAP web services > the server uses Hibernate and MySQL. > > 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. > > the next time I open the TopicMap, again the transaction is closed, and > the > function does the > same thing, and saves the changes. > > 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 t= he > 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) > > There is more than a week now where I am puzled with this and any hint, > idea, anything, would be highly appreciated > > could be a good idea to force closing the transaction, or commit? > > Thank you in advance. > Cheers > > > protected void save(PersistenceWrapper tmobject, String id) throws > DuplicateObjectIDException > { > if (id =3D=3D null) > { > id =3D m_idgen.getID(); > } > > try > { > TopicMapObjectDataObject dataObject =3D ((TopicMapObjectDataObje= ct) > tmobject.m_dataObject); > > if (m_provider.isTransactionOpen()) > { > System.out.println ("transaction is open"); > checkID(m_provider.getOpenTransaction(), id); > dataObject.setObjectId(id); > > 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(); > > try > { > checkID(m_provider.getOpenTransaction(), id); > dataObject.setObjectId(id); > > 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; > } > } > > if (tmobject instanceof TopicImpl) > { > > m_provider.registerTopic(tmobject.getPersistenceId(),(TopicImpl) > tmobject); > } > } > catch (DuplicateObjectIDException ex) > { > throw ex; > } > catch (Exception ex) > { > throw new TopicMapRuntimeException("Storage Exception.", ex); > } > } > > > ____________________________________________________________________ > 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. > > > ------------------------------------------------------- > 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 > ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi= les 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_idv37&alloc_id=16865&op=3Dick _______________________________________________ Tm4j-users mailing list Tm4...@li... https://lists.sourceforge.net/lists/listinfo/tm4j-users=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. |