If I was not using hibernate, I would use jdbcTemplate to make a db call like:
getJdbcTemplate().update("....")
I did this in the past, I didn't write any xml bean configuration or use any annotations for Transactions. So what kind of transaction scope did I have then?
Currently when using spring mvc with hibernate, i'm injecting the sessionManager (not using HibernateDaoSupport) and I put the @Transaction annotation on my service class (which uses the Dao).
@Service
@Transactional
public class UserServiceImpl extends UserService {
@Autowired
UserService userService
@Override
public User getUser(int id) {
return userDao.get(User.class, id);
}
}
My application context XML has:
<context:component-scan base-package="com.myapp"/>
<mvc:annotation-driven/>
<bean id="dataSource" .../>
<bean id="sessionFactory" .../>
<tx:annotation-driven />
At this point I really don't care about transactions spanning more than a single db call, and I want things to be as fast as possible.
How can I do exactly what the JdbcTemplate does?
What are the various options when it comes to transactions, specifically looking for ways to minimize table/row locking as much as possible (I'm guessing what I want is what jdbcTemplate did for me out-of-the-box).