• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Transactional read only

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi List[],
The read is only for read operation (I mean it is used for select but not insert).

But when it calls the insert method its inserting the data.Which i think it should not be.

Please let me know where i am wrong.

however my code is declare like this:
And xml look like



 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it should through an exception.

Just a small note you only need

<tx:transaction-driven/>

Since it automatically creates proxies, and your transactionManager is called transactionManager, which is the default value for that property.

Mark
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
When i use this <tx:annotation-driven />.I get exception
Exception in thread "main" java.lang.ClassCastException: $Proxy5 cannot be cast to com.Sem.MyDAO
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pankaj semwal wrote:Hi Mark,
When i use this <tx:annotation-driven />.I get exception
Exception in thread "main" java.lang.ClassCastException: $Proxy5 cannot be cast to com.Sem.MyDAO



You should change your code to create an interface for that class then have your DAO implement that class. It is best Java practice or best OO practice to code to interfaces, and Spring really want you to have interfaces to make it all run smoothly. So Spring actually forces you into that best practice.

Mark
 
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic