以<Categary> 和<Item> 为例。
categary_id, Item表中定义了fk,reference to categary 表中的categary_id.
在Item hibernate定义中,不需要指定<property name="categry_id" type="integer" />
否则就必须在<many-to-one>中,指定 insert="false" update="false".如果没有定义则报错。
测试程序很简单,Item i1=(Item)session.get(Item.class, new Integer(3));
然后就i1.getName();
i1.getCategary.getName();
观察console会发现只有access Categary的时候,hibernate 会根据categary_id , select categary get the row。