濡傛灉姣忎釜緹庡コ閮芥湁鑷繁鐨勫鎴瘋祫婧愶紙涓嶈鎯蟲浜嗭紒錛夛紝閭d箞闇瑕佹煡璇㈡嫢鏈夊鎴稧ates鐨勭編濂蟲庝箞鍔烇紵
浣跨敤Criteria鍙互鏈変袱縐嶆柟娉曪細
1錛?br />
DetachedCriteria beautyCriteria = DetachedCriteria.forClass(Beauty.class).createCriteria("customers");
beautyCriteria.add(Restrictions.eq("name", "Gates")):
2錛?br />
DetachedCriteria beautyCriteria = DetachedCriteria.forClass(Beauty.class).createAlias("customers", "c");
beautyCriteria.add(Restrictions.eq("c.name", "Gates")):
鎺ョ潃鏈変簡鏂扮殑瑕佹眰錛屽勾綰お澶х殑緹庡コ涓嶈錛岃繕鏄煡鎵炬嫢鏈夊鎴稧ates鐨勶紝鏉′歡濡備笅錛?br />
DetachedCriteria beautyCriteria = DetachedCriteria.forClass(Beauty.class, "b").;
DetachedCriteria customerCriteria = beautyCriteria.createAlias("customers", c");
beautyCriteria.add(Restrictions.le("b.age", new Long(20))):
customerCriteria.add(Restrictions.eq("c.name", "Gates")):
----------------------------------------------------------------------------------------------
<prop key="hibernate.hbm2ddl.auto">update</prop>
鍏朵腑update琛ㄧず鍔犺澆hibernate鑷姩鏇存柊鏁版嵁搴撶粨鏋勶紝浣犱篃鍙互鐢╟reate,浣嗚繖鏍蜂綘鏁版嵁搴撲腑鐨勬墍鏈夋暟鎹兘浼氳娓呴櫎錛屼及璁′綘鐜板湪鍐欑殑鏄痭one,鎵浠ヤ笉浼氳嚜鍔ㄧ敓鎴?nbsp;

]]>