i have following spring/hibernate configs:
<bean id="sessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean"> <property name="datasource" ref="jndidatasource" /> <property name="annotatedclasses"> <list> ... </list> </property> <property name="hibernateproperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.oracle10gdialect</prop> <prop key="hibernate.show_sql">true</prop> </props> </property> </bean> <tx:annotation-driven transaction-manager="transactionmanager"/> <bean class="org.springframework.dao.annotation.persistenceexceptiontranslationpostprocessor"/> <bean id="transactionmanager" class="org.springframework.orm.hibernate4.hibernatetransactionmanager" p:sessionfactory-ref="sessionfactory" />
i extensively using spring transaction annotations control transaction propagation methods throughout code base. working great.
i have need perform update affect many rows @ once , want blend in rest of transaction logic. last thing want bull in china shop , load objects memory , loop through them changing them 1 @ time.
i trying like:
@autowired private sessionfactory sessionfactory; ... string hql = "update table_name set column_list id in :list"; // see transaction , error when try start new one. transaction trans = sessionfactory.getcurrentsession().gettransaction(); query query = sessionfactory.getcurrentsession().createsqlquery(hql); query.setparameterlist("list", listofids); success = (query.executeupdate() == listofids.size());
i have tried dropping method own transaction instructions, not seeing evidence being executed (other lack of errors).
what recommended way include custom hibernate sql spring managed transactions?
thanks lot.
Comments
Post a Comment