spring - CGLIB proxy not getting created for Transactional Proxies -


here doing:

@component("jdbcbookdao") public class jdbcbookdao extends jdbcdaosupport implements bookdao{  @autowired public void injectdatasource(datasource datasource){     setdatasource(datasource); }  @transactional public int getstock(int isbn){     string sql = "select bs.stock book b, book_stock bs b.id=bs.book_id , b.isbn=?";     return getjdbctemplate().queryforint(sql, isbn); } } 

and in application context, have declared:

<tx:annotation-driven proxy-target-class="true"/>  

with config, expected when fetch jdbcbookdao context, cglib proxy(as have set proxy-target-class true). when debug, comes instance of jdkdynamicaopproxy. can 1 please explain why jdk proxy getting created when requested cglib proxy?

thanks.

spring source code object according if use interface jdk proxy, if use normal class cglib.

e   public aopproxy createaopproxy(advisedsupport config) throws aopconfigexception {     if (config.isoptimize() || config.isproxytargetclass() || hasnousersuppliedproxyinterfaces(config)) {         class targetclass = config.gettargetclass();         if (targetclass == null) {             throw new aopconfigexception("targetsource cannot determine target class: " +                     "either interface or target required proxy creation.");         }         if (targetclass.isinterface()) {             return new jdkdynamicaopproxy(config);         }         if (!cglibavailable) {             throw new aopconfigexception(                     "cannot proxy target class because cglib2 not available. " +                     "add cglib class path or specify proxy interfaces.");         }         return cglibproxyfactory.createcglibproxy(config);     }     else {         return new jdkdynamicaopproxy(config);     } }nter code here 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -