sql简单学习---备忘

2:Hibernate

    public boolean deleteFlowerById(int id) {
        Session session = sessionFactory.openSession();
        Transaction ts = session.beginTransaction();
        System.out.println("id--------:"+id);
        Query query=session.createQuery("from Flower where flowerid="+id);
        List flowers=query.list();
        session.delete((Flower) flowers.get(0));
        ts.commit();
        session.close();
        return true;
    }

 

posted @ 2017-05-09 17:49  开文博客园  阅读(144)  评论(0编辑  收藏  举报