还有关于proxy的问题
The runtime type of the proxies will be a subclass of Order. Note that the proxied class must implement a default constructor with at least package visibility. 
在它的文档上是这么说的
为什么说 代理的类型时order的子类呢 而不是order本身呢?
还有关于proxy的问题
The runtime type of the proxies will be a subclass of Order. Note that the proxied class must implement a default constructor with at least package visibility. 
在它的文档上是这么说的
为什么说 代理的类型时order的子类呢 而不是order本身呢?
proxy:
你可以load一个对象,看看它的实际类型是什么,再看看它的
继承树及实现接口。
The runtime type of the proxies will be a subclass of Order. 
它说这里的proxy是 order 的子类   迷惑
    ......
    
        .....
    
Firstly, instances of Cat will never be castable to DomesticCat, even if the underlying instance is an instance of DomesticCat
这里说 cat 类不能够造成它的子类DomesticCat  迷惑
Cat cat = (Cat) session.load(Cat.class, id);  // instantiate a proxy (does not hit the db)
if ( cat.isDomesticCat() ) {                  // hit the db to initialize the proxy
DomesticCat dc = (DomesticCat) cat;       // Error!
    ....
}
Secondly, it is possible to break proxy ==.
Cat cat = (Cat) session.load(Cat.class, id);            // instantiate a Cat proxy
DomesticCat dc = 
    (DomesticCat) session.load(DomesticCat.class, id);  // required new DomesticCat proxy!
System.out.println(cat==dc);       
这一段也没明白 这里的break proxy == 是什么意思
However, the situation is not quite as bad as it looks. Even though we now have two references to different proxy objects, the underlying instance will still be the same object:
cat.setWeight(11.0);  // hit the db to initialize the proxy
System.out.println( dc.getWeight() );  // 11.0
这里为何 cat 和dc 怎么又是同一个对象呢?? 迷惑
能解释一下吗? 谢谢
class name="eg.Cat" proxy="eg.Cat"
    ......
    subclass name="eg.DomesticCat" proxy="eg.DomesticCat"
        .....
    /subclass
/class
比如说你为Cat指定proxy="Cat",hibernate会继承Cat,生成一个代理类,就叫CatProxy(我随便取的)吧
同样对DomesticCat,hibernate会继承DomesticCat,生成一个代理类,就叫DomesticCatProxy吧
Cat cat = (Cat) session.load(Cat.class, id); // instantiate a proxy (does not hit the db)
//cat的实际类型就是CatProxy,你可以调用cat.getClass().getName()和cat.getClass().getSuperClass().getName()就知道了
if ( cat.isDomesticCat() ) { // hit the db to initialize the proxy
DomesticCat dc = (DomesticCat) cat; // Error!
//从CatProxy转型到DomesticCat,显然不对
....
}
Secondly, it is possible to break proxy ==.
Cat cat = (Cat) session.load(Cat.class, id); // instantiate a Cat proxy
DomesticCat dc = 
(DomesticCat) session.load(DomesticCat.class, id); // required new DomesticCat proxy!
System.out.println(cat==dc); 
这一段也没明白 这里的break proxy == 是什么意思
//就是会打出false,cat和de的类型分别是CatProxy和DomesticCatProxy,怎么会相等呢?
However, the situation is not quite as bad as it looks. Even though we now have two references to different proxy objects, the underlying instance will still be the same object:
cat.setWeight(11.0); // hit the db to initialize the proxy
System.out.println( dc.getWeight() ); // 11.0
//这两个proxy的底层是同一个对象
还能和我说说在hibernate中的Cache的问题吗
我看文档上说 有这几种Read Only Cache,Read / Write Cache,Nonstrict Read / Write Cache
在具体应用上 怎么使用呢?