From: Kal A. <ka...@te...> - 2005-08-10 07:41:46
|
Hi George, I think that it is exactly the problem that you suspect. When the transaction is closed, the results set is also closed. What you will need to do is to wrap your use of the tolog results in its own transaction. So you will need a few extra calls in your sample code: George Tryfon wrote: >Properties props = new Properties (); > >props.setProperty >("hibernate.dialect","net.sf.hibernate.dialect.MySQLDialect"); >props.setProperty >("hibernate.connection.driver_class","com.mysql.jdbc.Driver"); >props.setProperty ("hibernate.connection.url","jdbc:mysql://localhost/etm"); >props.setProperty ("hibernate.connection.username", "root"); >props.setProperty ("hibernate.connection.password", "123"); > >TopicMapProviderFactory tmpf = new TopicMapProviderFactoryImpl(); >TopicMapProvider provider = tmpf.newTopicMapProvider(props); > >Map mapFeatures = new HashMap (); >TMAPITopicMapSystemImpl tmApiSystImpl = new TMAPITopicMapSystemImpl >(tmpf.getClass().getName(), props, mapFeatures); > >Locator loc = provider.getLocatorFactory().createLocator ("URI", tmName); >org.tm4j.topicmap.TopicMap tm = provider.getTopicMap (loc); > >QueryEvaluator qe = QueryEvaluatorFactory.newQueryEvaluator (tm); > > ProviderTransaction txn = provider.openTransaction(); >TologResultsSet rSet = qe.execute ("topic($T)?"); > > > > // Do stuff with rSet txn.abort(); What *should* happen is that the underlying Hibernate topic map provider code should use the transaction you explictly opened for all lookup operations involved in processing the tolog query and it should not try and close the transaction (because it did not open it). I guess this is really a workaround for an underlying problem which is that the Tolog query implementation is not doing the transaction wrapping itself. Although the real issue at the heart of this is that the tolog implementation for Hibernate should be making more use of SQL or Hibernate's query language instead of translating the query into operations against the TM4J API. Neither of those changes are going to happen quickly to the code base (unless someone wants to volunteer!), so in the meantime I recommend that you do this explicit wrapping in your code. In a way it is clearer anyway - even if it does require a bit more typing! Hope this helps**, Kal ** Disclaimer - I haven't actually tried this, but it is my best guess, and its the way that I worked around other issues with iterators returned by the Hibernate implementation. |