0

Trying to delete an unmapped class/record via the NHibernate sql api. But can't seem to get it working. Does anything look wrong with this?

session = NHibernateHelper.GetCurrentSession();

        tx = session.BeginTransaction();
        using (tx)
        {
            session.CreateSQLQuery("DELETE FROM tb_category WHERE parentID = :parentID").SetInt64("parentID",pID);

            tx.Commit();
        }

Any help appreciated.

user17510
  • 1,529
  • 5
  • 19
  • 37

1 Answers1

4

I think, you have to execute the Query to make it do something.

You're just creating a Query and setting it's parameters.

In Hibernate there is an .executeUpdate() method for the SQLQuery object that runs the native query.

Prof. Falken
  • 23,276
  • 18
  • 98
  • 168
m_vitaly
  • 11,658
  • 5
  • 47
  • 61