• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Transactional read only

 
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • 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: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • 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 I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!