createCriteria sem transação

0 respostas
B

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:193

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:

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

DAO:

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

Barenko

Criado 2 de fevereiro de 2009
Respostas 0
Participantes 1