java - How hibernate change classes or object at run time -


i trying understand how hibernate work in sense how putting @entity on class makes persistent class ? i.e

      @entity     class a{         private int b;          public int getb(){         return b;          }          public void setb(int b){          this.b = b;         }     }  behaves below written class @ runtime      class a{         private int b;          public int getb(){          return (sql code fetch b db)         }          public void setb(int b){         (sql code set b in db)(b);         }     } 

if using reflection how changing code inside methods ?

hibernate proxied / runtime-weave class. meaning when other classes invoke methods of class, doesn't invoke directly, invokes proxy. proxy contains logic involves persistence context operations.

have @ library such cglib or aspectj if want delve deeper in topic (not ones used hibernate)


Comments