假设我数据库有这样两张表 teacher(tid,tname,title) 和 student(sid,sname,age,tid), 将teacher表的ID作为student表的外键,然后在teacher.java和student.java这两个实体类中我要如何添加注解来实现SQL语句中的select * from teacher as t,student as s where t.tid=s.tid .以及我的HQL语句该怎么写?
------解决方案--------------------
我都是用工具自动生成的
------解决方案--------------------
- XML code
<class name="Student"> <id name="id" column="studentId"> <generator class="native"/> </id> <many-to-one name="teacher" column="teacherId" not-null="true"/></class><class name="Teacher"> <id name="id" column="teacherId"> <generator class="native"/> </id></class>