Wednesday, November 18, 2015

Hibernate Delete Query

Hibernate Delete Query


This is the program to Delete a row (Object) from the database, just like using delete query in the jdbc program..
Files required to execute this program..
  • Product.java (My POJO class)
  • Product.hbm.xml (Xml mapping file )
  • hibernate.cfg.xml (Xml configuration file)
  • ClientProgram.java(java file to write our hibernate logic)

Product.java (POJO)

Product.hbm.xml

hibernate.cfg.xml


ClientProgram.java



As usual compile all .java programs and run ClientProgram.java to see the output

Eclipse output

Oracle DB, Before Run The Program

Oracle DB, After Run the program

Note:

  • To deleting the object( 1 row) form the database we need to call delete method in the session.
  • In the hibernate we have only one method to delete an object from the database that is what i have shown you here..

No comments:

Easy Way to Handle Android Notifications

Android Notifications Android Toast class provides a handy way to show users alerts but problem is that these alerts are not persist...