I have already posted this question before but as the thread is little old I think I am not getting reply so sorry for duplicating but my issue is something related to spring transaction.
I am facing a similiar problem with Spring Transaction management. I am using hibernate as ORM framework. And below is the excerpt of spring configuration file of my application which uses spring transaction management.
<context:annotation-config/>
<context:property-placeholder location="classpath:spring.properties"/>
<tx:annotation-driven transaction-manager="transactionManager"/>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="create*" rollback-for="Exception"/>
<tx:method name="update*" rollback-for="Exception"/>
<tx:method name="remove*" rollback-for="Exception"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="ServiceOperation" expression="execution(* com.shaikh.demo.*Service.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="ServiceOperation"/>
</aop:config>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
All my *Service Classes are annotated by @Transactional
annotation.
In my hibernate DTO classes I am modifying return value for each get* method as below because I want to remove all the non-ascii characters. The data in the database is for read-only purpose just for listing down the records ,before this I need to remove non-ascii characters which are creating problems. Database is Oracle 11g.
e.g. For attribute accountNumber
public String getAccountNumber(){
return StringHelper.removeNonAscii(this.accountNumber);
}
I have read that we are changing the state of the DTO object and making it dirty so hibernate is flushing this dirty objects into the db. I can see the update statements in logs.
Here my questions are :
1.) I am making DTO objects dirty but I have marked get* related methods as Read-only so how can hibernate is flushing changes to the db.
2.) How can I solve my problem related to this Non Ascii character without changing my database data. Am I missing something ?