Robbie
Robbie

Reputation: 53

Deleting within hibernate

When running the delete method for an object it does not get delelted from the database

Delete query

 @NamedQuery(
                        name = "deleteAppointment",
                        query = "delete Appointment t where t.id = : id"
                ),

Method for deleting the appointment

   public void deleteAppointment2(Integer appId){
        Session session = factory.openSession();
        Transaction tx = null;
        try {
            tx = session.beginTransaction();
            TypedQuery query = session.getNamedQuery("deleteAppointment");
             query.setParameter("id", appId);
             query.executeUpdate();
        }catch (HibernateException e){
            e.printStackTrace();
        }
    }

Yet when I run the method it does not delete the appointment

Upvotes: 0

Views: 43

Answers (1)

Lesiak
Lesiak

Reputation: 25936

You are never executing your TypedQuery

Upvotes: 2

Related Questions