这样看你的Account是主表,就是one的这边。
UserCommon是子表,many的这边。
在Account类中增加:
private Set ucs;//放置UserCommon实体集在UserCommon类中增加:
private Account account;//指向主表在Account.hbm.xml中:
        <set name="ucs" cascade="none" table="UserCommon所对应的数据表的表名"> 
         <key column="UserCommon所对应的数据表中指向Account的id的列名" /> 
         <one-to-many class="UserCommon" /> 
        </set>
在UserCommon.hbm.xml中:
        <many-to-one name="account" class="Account" column="UserCommon所对应的数据表中指向Account的id的列名" cascade="none"/>
这些配置中对应的配置可以参看hibernate中文文档,根据你的实际应用需要来配。

解决方案 »

  1.   

    楼上的说反拉
    UserCommon.hbm.xml
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
                                       "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
    <hibernate-mapping>
    <class name="xxx.UserCommon" table="UserCommon">
    <id name="objectID" column="objectID" type="integer">
    <generator class="native"/>
    </id>
    <property id="id" column="id" type="string"/>
            <property id="userID" column="userID" type="string"/>
            <property id="sequence" column="sequence" type="integer"/>
    <bag name="Account" cascade="all" order-by="id">
    <key column="objectID"/>
    <one-to-many class="xxx.Account"/>
    </bag>
    </class>
    </hibernate-mapping>Account.hbm.xml
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
                                       "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
    <hibernate-mapping>
    <class name="xxx.Account" table="Account">
    <id name="id" column="id" type="integer">
    <generator class="native"/>
    </id>
    <property name="accountCode" column="accountCode" type="string"/>
            <property name="accountTypeID" column="accountTypeID" type="string"/>
    <many-to-one name="UserCommon" column="objectID" class="xxx.UserCommon"/>
    </class>
    </hibernate-mapping>xxx为你的包的路径
      

  2.   

    to loverisyour(我是民工又咋的,不能搞开发啊!) :
       恕我学识浅薄,不过我确实还没见过你这样的配置.
       还有,楼主的UserCommon表通过一个外键objectID与Account表的主键id关联,UserCommon很明显的就是子表,Account是主表,你怎么说是反了?
      

  3.   

    public class UserCommon {
    private String id;
             private String userID;
    private String objectID;
    private Integer sequence;
    //存放Account对象的列表
    private List accounts=new ArrayList();//该类不是有个Account的集合吗
    }
    我没认真看啊,我还以为objectID是主键啊 :(
      

  4.   

    还有我才发现objectID是String 型啊,哈哈,我还以为是个简单的one to many呢
      

  5.   

    to: IceCraft(心淡情浓) 
    这两个表如果用SQL语句连接起来,如下:
    Select  UserCommon.id,
            Account.id AS AccountID, Res_Account.AccountCode
    FROM Res_User_Common 
            INNER JOIN Account ON _Account.id=UserCommon.objectID
    WHERE UserCommon.UserID='5663d688-9110-4e9b-a3f8-fa3ef22f0e45'也就是:
    我从UserCommon中选出一个数据对象usercommon后,usercommon中就要有一个相应的Account对象account,像你那样配置能实现嘛?
      

  6.   

    只要你查出一个usercommon对象,通过usercommon.account就可以得到Account对象了。