数据未插入多对多映射?

时间:2011-11-19 18:52:48

标签: hibernate-mapping

我有三个数据库表

  1. 路线(ROUTE_ID)
  2. 止动件(stop_id)
  3. route_stop(route_id,stop_id)---映射表
  4. Route.hbm.xml

    <set name="stops" table="route_stop" cascade="all"><key column="route_id" /><many-to-many column="stop_id" class="com.trackingsystem.model.Stop" /></set>
    

    Stop.hbm.xml

    <set name="routes" table="route_stop" cascade="all"><key column="stop_id" /><many-to-many column="route_id" class="com.trackingsystem.model.Route" />
    

    但数据未插入数据库,

    显示这些选择查询

        
    
    Hibernate: 
        /* get current state com.trackingsystem.model.Stop */ select
            stop_.stop_id,
            stop_.stop_name as stop2_106_,
            stop_.lattitude as lattitude106_,
            stop_.langitude as langitude106_ 
        from
            trackingsystem.stop stop_ 
        where
            stop_.stop_id=?
    
    
    Hibernate: 
        /* get current state com.trackingsystem.model.Stop */ select
            stop_.stop_id,
            stop_.stop_name as stop2_106_,
            stop_.lattitude as lattitude106_,
            stop_.langitude as langitude106_ 
        from
            trackingsystem.stop stop_ 
        where
            stop_.stop_id=?
    

    问题出在哪里?

1 个答案:

答案 0 :(得分:1)

问题是我没有冲洗会话。之后,每件事都没问题。 感谢。