This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Spring and the fly likes Transactional read only Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Transactional read only " Watch "Transactional read only " New topic
Author

Transactional read only

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
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



Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 300
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
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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
 
jQuery in Action, 2nd edition
 
subject: Transactional read only