hibernate 中的 lazy="proxy" 和 lazy="no-proxy" 的區別

Child   <-   many-to-one   ->Parent  
   
  class   Child   {  
      private   Parent   parent;  
   
      public   Parent   getParent   (){  
          return   this.parent;//訪問了實例變量  
      }  
       
  }  
   
  class   Parent   {  
      private   String   name;  
   
      public   String   getName(){  
          return   this.name;//訪問了實例變量  
      }  
   
      public   void   f(){  
          System.out.println("invokeing   f()");//沒有訪問實例變量  
      }  
  }  
   
  如果   many-to-one   的lazy設爲proxy,當child.getParent().getName()或child.getParent().f()時,parent都會被抓取,若設爲no-proxy,調用child.getParent().f()時,parent是不會被抓取的,同時這種方式需要編譯時字節碼增強,否則和proxy沒區別。

 

本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/huxiweng/archive/2010/04/14/5485282.aspx

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章