简体   繁体   中英

spring transaction management with jdbctemplate

I am running a java project using jdbctemplate in which update of 2000 records is happening with batch size of 500 records.

Since, i am using single update query would there improvement in application if i would use spring transaction management ?

As per my knowledge it would help in the performance as code is going to hit the database only once

even I would suggest to use

@Override
public <S extends Classname> Iterable<S> save(Iterable<S> arg0);

Which save the entities present in list directly to database without using either jdbcTemplate or transaction management

this is decided by your requirement. if 2000 records must constants,so you have to use transaction management,if not , you can deal one record every time.

It can definitely help you. You can make the 500 record batch calls one by one in a Java method annotated with @Transactional annotation. That way, spring will roll back the whole operation in the event that any of the update fails.

PS: I haven't specified any XML configurations where you have to specify your transaction manager. You can add a suitable one meeting your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM