qq_35681362 2017-03-13 08:52 采纳率: 33.3%
浏览 1066

Hibernate多对一删除问题

为什么我只能删除多方的,而不能删除一方的

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);
}

  • 写回答

2条回答 默认 最新

  • 犊子哥哥 2017-03-13 10:49
    关注

    如果你把一的那方删除了,多的数据怎么办,不剩下整成干瞪眼儿了

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?