createCriteria sem transação

0 respostas
barenko

Olá, estou utilizando hibernate3, e preciso que a aplicação seja autocommit. Porém ocorre erro sempre que eu tento utilizar o createCriteria, alguém sabe me dizer como posso contornar esse problema?

<blockquote>AspAplicacaoHome:107 - find by example failed

org.hibernate.HibernateException: createCriteria is not valid without active transaction

at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:297)

at $Proxy0.createCriteria(Unknown Source)

at br.com.synchro.servicepack.log.control.AspAplicacaoHome.findByExample(AspAplicacaoHome.java:100)

at br.com.synchro.servicepack.log.ServicePackLogImpl.getApplication(ServicePackLogImpl.java:1103)

at br.com.synchro.servicepack.Core.isInstalled(Core.java:1938)

at br.com.synchro.servicepack.Core.loadLog(Core.java:139)

at br.com.synchro.servicepack.Core.loadXML(Core.java:157)

at br.com.synchro.servicepack.swing.ServicePackGUI.inicializeProcess(ServicePackGUI.java:741)

at br.com.synchro.servicepack.swing.ServicePackGUIThread.run(ServicePackGUI.java:1087)

at java.lang.Thread.run(Thread.java:595)

</blockquote>

Trecho do hibernate.config.xml:

&lt;property name="hibernate.bytecode.use_reflection_optimizer"&gt;false&lt;/property&gt; &lt;property name="hibernate.cache.provider_class"&gt;org.hibernate.cache.NoCacheProvider&lt;/property&gt; &lt;property name="hibernate.cacheable"&gt;false&lt;/property&gt; &lt;property name="hibernate.cacheMode"&gt;REFRESH&lt;/property&gt; &lt;property name="hibernate.cache.use_query_cache"&gt;false&lt;/property&gt; &lt;property name="hibernate.connection.pool_size"&gt;2&lt;/property&gt; &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt; &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/property&gt; &lt;property name="hibernate.show_sql"&gt;true&lt;/property&gt; &lt;property name="connection.autocommit"&gt;true&lt;/property&gt;

DAO:

public List&lt;AspAplicacao&gt; findByExample(AspAplicacao instance) { List&lt;AspAplicacao&gt; results = (List&lt;AspAplicacao&gt;) sessionFactory.getCurrentSession().createCriteria("pkg.bean.AspAplicacao").add(create(instance)).list(); return results; }

Rafael

Criado 2 de fevereiro de 2009
Respostas 0
Participantes 1