wood burning stoves*
The moose likes Object Relational Mapping and the fly likes Hibernate not deleting rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate not deleting rows" Watch "Hibernate not deleting rows" New topic
Author

Hibernate not deleting rows

prasad regula
Greenhorn

Joined: Jul 03, 2006
Posts: 24
I am trying to delete rows from database using hibernate. It is returning the row count of the number of rows deleted, when I go to database the rows are still existing

Here was my query


My code is



PRSubject
prasad regula
Greenhorn

Joined: Jul 03, 2006
Posts: 24
If I change that to <sql-query> as below I am getting the following error




SEVERE: Update queries only supported through HQL

With <query> I am getting the following error





SEVERE: could not execute update query
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Begin a transaction before you delete the rows and then commit the transaction after the rows are deleted, this should do it


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
prasad regula
Greenhorn

Joined: Jul 03, 2006
Posts: 24
I added Transaction statement

Transaction transaction = session.beginTransaction();
//code to delete rows
transaction.commit();

This time I am getting that the rows are being deleted, but they are not getting deleted. I tried to deleted the row using jdbc code. The row is getting deleted.
prasad regula
Greenhorn

Joined: Jul 03, 2006
Posts: 24
Solution given by Ankit Garg is working fine. I commited a mistake, and it is working fine now. Thanks Ankit.
 
 
subject: Hibernate not deleting rows
 
Similar Threads
Could not parse mapping document from resource PojoTestTable.hbm.xml
how to dynamically set values in check box
What hibernate.hbm2ddl.auto value to use?
Issue with String types when hibernate returns list of Object arrays
Caught a NonUnique Exception while adding more rows to the table.