急急!!hibernate left join 取join表字段值为null??
---------------------------------Employee实体类------------------------------public class Employee {
private String id;
private String group_id;
private String name;
private Group group;
getter() setter()略。。。。
}
-------------------------------Group 实体类------------------------------------
public class Group {
private String id;
private String group_code;//班次ID
private String name;//名称
private Set<Employee> employee;
getter() setter()略。。。
}
---------------------------------Emoployee.hbm.xml----------------------------------
<hibernate-mapping>
<class name="com.naite.entity.Employee" table="ut_employee" >
<id name="id" type="java.lang.String">
<column name="ut_employee_id" length="36" />
<generator class="uuid.hex"/>
</id>
<property name="group_id" type="java.lang.String" lazy="true">
<column name="ut_group_id" length="36" />
</property>
<property name="name" type="java.lang.String">
<column name="name" length="50" />
</property>
<many-to-one name="group" class="com.naite.entity.Group" column="ut_group_id"
insert="false" update="false"/>
</class>
</hibernate-mapping>
----------------------------------------Group.hbm.xml--------------------------------------
<hibernate-mapping>
<class name="com.naite.entity.Group" table="ut_group" >
<id name="id" type="java.lang.String">
<column name="id" length="32"/>
<generator class="uuid.hex"/>
</id>
<property name="group_code" type="java.lang.String" lazy="true">
<column name="ut_group_id" length="36" />
</property>
<property name="name" type="java.lang.String" lazy="true">
<column name="name" length="50" />
</property>
<set name="employee">
<key column="id"></key>
<one-to-many class="com.naite.entity.Employee" not-found="ignore"/>
</set>
</class>
</hibernate-mapping>
-----------------------------------------hql语句--------------------------------------
String sql="select e,g.name from Employee e left join fetch e.group g where 1=1";
List<Employee> list=getHibernateTemplate().find(sql, pramlist.toArray(new Object[0]));
------------------------------------------查询后结果------------------------------------
g.name=null; Employee.group内的各个字段属性也为Null
------------------------------------------想要结果--------------------------------------
查出每位员工所在的组的名称(Group.name);员工未分组的对应的组名(Group.name)为空
Hibernate left join 多表字段显示 --------------------编程问答-------------------- select e,g.name from Employee e left join fetch e.group g where 1=1
这语句怎么那么别扭,left join 是和on一起用的,俩表关联的字段写上 --------------------编程问答-------------------- select e,g.name from Employee e left join fetch e.group g where 1=1
这语句怎么那么别扭,left join 是和on一起用的,俩表关联的字段写上 --------------------编程问答-------------------- select e,g.name from Employee e left join fetch e.group g where 1=1
hibernate里不是没有left join on吗 纯sql语句我会写,但是HQL怎么写啊?求大侠帮助……菜鸟小弟多谢
补充:Java , Java EE