I am able to resolve this issue by using below code in context xml file.
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- the transactional semantics... -->
<tx:attributes>
<!-- all methods starting with 'get' are read-only -->
<tx:method name="get*" read-only="true"/>
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allServiceMethods" expression="execution(* com.test.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allServiceMethods"/>
</aop:config>
As by default read-only="false"
for @Transactional
annotation.
So we need to make it as read-only="true"
for all read operation(Thanks Affe for pointer)
to set read-only="true"
for all select select operation make sure that you start your method name from get
and rest below code will code for us. you can change your below configuration as per your need.
<tx:method name="get*" read-only="true"/>
For more information you can refer to below link