Class Account{ String accountno;
Customer owner;
........
}Class Customer{.....
}一个用户有多个account,一个account 只属于一个用户, 想通过 accountno 读取到customer 对象。
select a.owner from Account a where a.accountNo="+accountno; 不行请指教怎样写sql , 多谢
Customer owner;
........
}Class Customer{.....
}一个用户有多个account,一个account 只属于一个用户, 想通过 accountno 读取到customer 对象。
select a.owner from Account a where a.accountNo="+accountno; 不行请指教怎样写sql , 多谢
如果是的话,我正好有这个例子。[email protected]给我留言,我发给你。
<many-to-one name="parent" column="parent_id" fetch="join"></many-to-one>private SshUser parent;
Account.hbm.xml
<many-to-one name="customer" class="Customer" fetch="select">
<column name="accountno" precision="22" scale="0" />
</many-to-one>
Customer.hbm.xml....
<set name="account" inverse="true" lazy="false">
<key>
<column name="accountno" precision="22" scale="0"></column>
</key>
<one-to-many class="Account" />
</set>
....