Hi,
I try to delete a table with an EntityManager from hibernate.
My step implement taskletStep :
My class is:Code:<bean id="step1" parent="taskletStep" > <property name="tasklet" ref="baseAdministrativeSupprimeTasklet" /> <property name="jobRepository" ref="jobRepository" /> </bean> <bean id="baseAdministrativeSupprimeTasklet" class="com.natixis.facturationnie.batch.writer.BaseAdministrativeSupprimeTasklet">
When the progamm call the "lquery.executeUpdate();", it throws aCode:public class BaseAdministrativeSupprimeTasklet implements Tasklet, InitializingBean { protected EntityManager entityManager; public ExitStatus execute() throws Exception { Query lquery = entityManager.createNativeQuery("delete from fac_maj_base_adm"); lquery.executeUpdate(); return ExitStatus.FINISHED; }
javax.persistence.TransactionRequiredException: Executing an update/delete query
There is no transaction started.
When I whant to do a select, I implement "SimpleStep" in the property file and
ItemReader in the class, it works fine!
The configuration of hibernate is:
Code:<persistence-unit name="applicationEntityManagerBatch" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.Sybase11Dialect" /> <property name="hibernate.query.substitutions" value="true 'Y', false 'N'" /> <property name="hibernate.show_sql" value="true" /> <property name="hibernate.use_sql_comments" value="true" /> <property name="hibernate.format_sql" value="true" /> <property name="hibernate.cache.use_second_level_cache" value="true" /> <property name="hibernate.cache.use_query_cache" value="true" /> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider" /> <property name="hibernate.jdbc.batch_size" value="10000" /> <property name="hibernate.max_fetch_depth" value="0" /> <property name="hibernate.order_inserts" value="true" /> <property name="hibernate.order_updates" value="true" /> </properties> </persistence-unit>
Why the transaction isn't started with the tasklet?
Have you a way to delete table with an entity manager?
Thanks in advance,
Sylvain


Reply With Quote