[原创]hibernate 一对一实践 by hjack[6]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

);
       */
       /*测试查询主题
       Topic topic = app.query(1);
       System.out.println(topic.getAuthor().getName());
       */
      } catch (Exception e) {
       // TODO 自动生成 catch 块
       e.printStackTrace();
      }
      
     }
    }

测试插入作者如图1所示,测试插入主题如图2所示,测试查询主题结果如下:
Hibernate: select topic0_.id as id1_, topic0_.name as name1_, topic0_.user_id as user_id1_, author1_.id as id0_, author1_.name as name0_ from topic topic0_ left outer join author author1_ on topic0_.user_id=author1_.id where topic0_.id=?
jack
生成的sql语句用到了join,查询结果为jack,与期望相符。

图一

本文关键:[原创]hibernate 一对一实践 by hjack
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top