<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Uchith on Medium]]></title>
        <description><![CDATA[Stories by Uchith on Medium]]></description>
        <link>https://medium.com/@uchith2191?source=rss-d5c6adee0a25------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6ich5DElVlh6e2FaWyD4Ew.png</url>
            <title>Stories by Uchith on Medium</title>
            <link>https://medium.com/@uchith2191?source=rss-d5c6adee0a25------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:56:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@uchith2191/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[@Transactional (Spring Data JPA)]]></title>
            <link>https://medium.com/@uchith2191/transactional-spring-data-jpa-fe7d22a3ff7a?source=rss-d5c6adee0a25------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe7d22a3ff7a</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[spring-data-jpa]]></category>
            <category><![CDATA[spring-jpa]]></category>
            <category><![CDATA[transactional]]></category>
            <dc:creator><![CDATA[Uchith]]></dc:creator>
            <pubDate>Sat, 14 Feb 2026 15:27:29 GMT</pubDate>
            <atom:updated>2026-02-14T15:27:29.233Z</atom:updated>
            <content:encoded><![CDATA[<p>@Transactional is an annotation used at the method or class level to handle the databse transactions declaratively.<br>When spring detects a bean with transactional method, it create a proxy object around the bean using Spring AOP.</p><p>When the transcational method is called, the call goes through the proxy instead of directly to the original bean. The proxy starts the transaction using the configured PlatformTransactionManager such as the JpaTransactionManager.</p><p>If the method executes successfully without any exception, the proxy commits the transaction. If there is any error or runtime exception, the proxy automatically rolls back the transaction.</p><p>This ensures ACID proerties.</p><p>Below is an example using @Transactional annotation</p><pre>@Service<br>public interface AccountService {<br><br>    @Transactional<br>    void transfer(Integer fromId, Integer toId, Double amount);<br>}</pre><pre>public class AccountServiceImpl implements AccountService {<br><br>    @Autowired<br>    private AccountRepository accountRepository;<br><br>    @Override<br>    public void transfer(Integer fromId, Integer toId, Double amount) {<br>        Account fromAccount = accountRepository.findById(fromId).get();<br>        Account toAccount = accountRepository.findById(toId).get();<br><br>        // deduct from sender<br>        fromAccount.setAccountBalance(fromAccount.getAccountBalance() - amount);<br>        accountRepository.save(fromAccount);<br><br>        //Simulate error<br>        if (true) {<br>            throw new RuntimeException(&quot;Something went wrong&quot;);<br>        }<br><br>        // Step 2: Add to receiver<br>        toAccount.setAccountBalance(toAccount.getAccountBalance() + amount);<br>        accountRepository.save(toAccount);<br><br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe7d22a3ff7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>