I have 2 tables, one table is
City Table ( int id, string name)
and my another table is
Distance table(int id,int cityId (FK city),int neighbourId(FK city))
I want to use Hibernate but I can't esta开发者_运维知识库blish a relationship between these tables in Hibernate.
what about something like
<class name="City" table="CITIES">
    <id name="id" type="integer">
      <generator class="native" />
    </id>
    <property name="name" />
    <set name="neighbours" table="DISTANCES">      
        <key column="city_id" />
        <many-to-one name="neighbour" class="City" />
    </set>
</class>
didn't test it though.
Ok, I can see any problem to do it normally.
<class name="City" table="CITY">
    <id name="id" type="integer">
      <generator class="native" />
    </id>
    <property name="name" />
</class>
<class name="Distance" table="DISTANCE">
    <id name="id" type="integer">
      <generator class="native" />
    </id>
    <many-to-one name="city" column="cityId" class="City"/>
    <many-to-one name="neighbour" column="neighbourId" class="City"/>
</class>
didn't test it neither.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论