hibernate应该在数据库中做关联
解决方案 »
- 急!!!关闭网页时怎样让session失效?
- frame中js控制div的位置
- Hibernate事务问题
- 如何访问局域网内某一台机子的C盘
- ?向服务器提交请求超过30秒无响应。
- 嵌套标签问题
- Hibernate中SessionFactory创建失败出现ExceptionInInitializerError异常和PropertyNotFoundException异常
- 点击提交按钮对应的action里,需要指定到网站的根目录么?
- 如家 汉庭 某酒店2000W数据 1.7 GB 泄露数据如何快速查询
- ehcache缓存首页启动报错
- 难道世界上只有4个人遇到过这个问题????google 搜出 3个!!!!!!!!
- 谁的速度比较快?
偶是新手啊,9999
目前我只会用JDBC查询
select user.username,college.collegename from user,college where user.userid=1 and user.collegeid=college.collegeid
用hibernate不知道怎么做了
<class name="com.fuqi.pojo.Bloguser" table="bloguser">
<id name="userid" type="integer">
<column name="userid" />
<generator class="native"></generator>
</id>
<property name="collegeid" type="integer">
<column name="collegeid" />
</property>
<property name="username" type="string">
<column name="username" length="50" not-null="true" />
</property>
</class>
</hibernate-mapping>
xml就配置什么关系
<property name="collegeid" type="integer">
<column name="collegeid" />
改成
<many-to-one name="college" class="com.fuqi.pojo.College" column="collegeid">
然后bloguser类对应的属性改成 private College college;
然后就可以了