aspose file tools*
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
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Transactional read only