为什么我只能删除多方的,而不能删除一方的
1.这是删除的方法 public void delete(Library library){
session = HibernateUtil.getSession();
try {
session.beginTransaction();
session.delete(library);
session.getTransaction().commit();
} catch (Exception e) {
e.printStackTrace();
session.getTransaction().rollback();
}
}
2.这是多方
<!-- properties are mapped to columns of table -->
<property name="author" type="string" not-null="true">
<column name="author"></column>
</property>
<many-to-one name="lkind" cascade="all" class="com.entity.Lkind">
<column name="lk_id"></column>
</many-to-one>
</class>
3.这是一方
<!-- properties are mapped to columns of table -->
4.这是servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
int id = Integer.parseInt(request.getParameter("id"));
Library library = new Library();
library.setId(id);
Grand g=new Grand();
g.delete(library);
request.getRequestDispatcher("information.jsp").forward(request, response);
}