我有一个实体,其中有一个列表。
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(name = "subject_group_join",
joinColumns = {
@JoinColumn(name="sub_group_id")
},
inverseJoinColumns = {
@JoinColumn(name="subject_id")
}
)
List<SubjectEntity> listOfSubjects;
主体实体如下:
@Entity
@Table(name="subject_details")
@NamedNativeQueries({
@NamedNativeQuery(name = "GET_SUBJECT_BY_CLASS",query = "call fetchAllSubjectByClass(:classId,:sessionId)",resultClass = SubjectEntity.class) ,
@NamedNativeQuery(name = "GET_OPTIONAL_SUBJECT_BY_CLASS",query = "call fetchOptionalSubjectByClass(:classId,:sessionId)",resultClass = SubjectEntity.class),
@NamedNativeQuery(name = "GET_CUMPULSORY_SUBJECT_BY_CLASS_NOT_GROUPED",query = "call fetchAllCumpulsorySubjectByClassNotGrouped(:classId,:sessionId)",resultClass = SubjectEntity.class),
@NamedNativeQuery(name = "GET_OPTIONAL_SUBJECT_BY_CLASS_NOT_GROUPED",query = "call fetchAllOptionalSubjectByClassNotGrouped(:classId,:sessionId)",resultClass = SubjectEntity.class),
})
public class SubjectEntity extends AbstractEntity{
private static final long serialVersionUID = 7320078093064615396L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="subject_id")
private long subjectId;
@Column(name="subject_name",length=32)
private String subjectName;
@Column(name="subject_code",length=32)
private String subjectCode;
@Column(name="description",length=512)
private String description;
@Column(name="subject_status")
private boolean subjectStatus;
当我通过 Hql“从 entity1”获取第一个实体列表时;它没有提供在 subjectEntity 中填充的所有数据,它只是在其中包含 id。