Transaction propagation in spring @required

    public String primaryTrans() {
        User u1 = new User(0,"test","");;
        User u2 = new User(0,"test1","");;
        return "index";

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    private void secondaryTrans() {
        // TODO Auto-generated method stub
        User u2 = new User(0,"test2","".repeat(300));;

Here i am manually raising DATA TOO LONG exception from secondary transaction, But it causes primary transaction also rolled back. How can we make sure that primary transaction to be committed irrespective of secondary transaction

>Solution :

In this case, since the second method is called from the same class, the second transaction is most likely not created. Springs transactional support uses AOP proxies to create transactions. The docs contain a description on why this will not work.

Leave a Reply