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 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题