hibernate 多对多单向查询问题
我的Action类调用另一个类的如下方法,Manager和Book为多对多关系,Manager中有books属性,但
查询成功以后,hibernate还将连接表中连接该Manager的记录删去,
Hibernate: delete from BORROW where MANAGER_ID=? (BORROW为连接表)
这是怎么回事啊 ????
public static Manager getManagerByName (String name)throws Exception{
Transaction tx=null;
try{
Session session=HibernateSessionFactory.currentSession();
tx=session.beginTransaction();
Query query=session.createQuery("from Manager m where m.name=:name");
List list=query.setString("name",name).list();
tx.commit();
return list.iterator().hasNext()?(Manager)list.iterator().next():null;
}catch(Exception ex){
tx.rollback();
throw new Exception();
}finally{
HibernateSessionFactory.closeSession();
}
}