In this lesson we will show how to delete rows from the underlying database using the hibernate. Lets first write a java class to delete a row from the database.
Create a java class:
Here is the code of our java file (DeleteHQLExample.java),
which we will delete a row from the insurance table using the query "delete from Insurance insurance where id = 2"
Here is the code of delete query: DeleteHQLExample.java
package roseindia.tutorial.hibernate;
|
Output:
| log4j:WARN No appenders
could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly. Hibernate: delete from insurance where ID=2 Deleted Row: 1 |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Hibernate Delete Query View All Comments
Post your Comment