Question

When I try to delete an object using HQL, I use hiberate's session.CreateQuery().executeUpdate() and it returns 1 item is deleted. However, in database, nothing has been deleted. After executeUpdate, I also did flush.

Could anyone give me some suggestion about what's wrong here?

Was it helpful?

Solution

You haven't committed an enclosing transaction. You need something like:

tx = session.beginTransaction()
session.createQuery().executeUpdate("...")
tx.commit()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top