1. 在配置hibernate文件时,对于一对多的关系,在多的一方 ( 即是many-to-one的一方 )都加上lazy=“false”, 虽然对于所有的实体关系来说并不是必需甚至是影响了性能。但是能避免因为延迟加载我出现的错误。
2.对于hibernate报的could not resolve property错误,多半是由于hql语句错误(或者是hibernate文件配置错误)。
比如advantageSubject(id, teacherId, subjectId) 例子中,当查找的时候sql语句应为 “from AdvantageSubject as a where a.teacher.teacherId = '090510220' ".
而不能是“from AdvantageSubject as a where a.teacherId = '090510220' ".