日期:2014-05-16  浏览次数:20510 次

hibernate一对多连接懒加载EAGER只能有一个,如果有多个报错,需要手动强制录入

CMS新媒体技术学到的



	public List<CmsProgram> searchProgramsByProgramIDs(String ProgramIDs) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
	try {
     		sb.append("from CmsProgram as p where p.programID in ("+ProgramIDs+")");
			System.out.println("----------------------HelloWorld  zzk");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		List<CmsProgram> list = this.getSession().createQuery(sb.toString()).list();
		for(CmsProgram program:list){
			Hibernate.initialize(program.getCmsPictures());
		}
		return list;
	}