0

I have seen this post about how to wrap JDBCTemplate in Db-transcation

My question is - how can I check this works?

@Transactional(rollbackFor={Exception.class})
public int insertLogAndGetId(ConfigActivityLog dbConfigChange) throws Exception {
    int idInDB = -1;
    if(insertLog(dbConfigChange))
    {
        idInDB = getLatestActivityWithStatus(dbConfigChange.actionStatus).id;
    }
    return idInDB;
}

I don't use other annotations like:

@Service
public class SomeService implements ISomeService {
    @Autowired
    private NamedParameterJdbcTemplate jdbcTemplate;
    @Autowired
    private NamedParameterJdbcTemplate npjt;
Community
  • 1
  • 1
Elad Benda2
  • 13,852
  • 29
  • 82
  • 157
  • If you don't use Spring annotations, I am assuming your service beans would declared either `XML` or `JavaConfig`. But why not use `JUnit`? – Manuel Jordan Oct 22 '16 at 13:40
  • There's no change so there's no reason to rollback? – mh-dev Oct 22 '16 at 14:38
  • if you don't use @service it won't be found by spring, so it is not working. Please clarify your question: what should work, and what exactly you want to know works: is it transactions are rolled back or transaction process? either way you have to do smth to DB inside method. – Andrii Plotnikov Oct 22 '16 at 14:49

0 Answers0