Hi,
Did any one use Native SQL for delete operations. We thought of using NativeSQL on Hibernate as we want to delete all the records in one go.
But the problem we do have is the HQL parser (ASTQueryTranslatorFactory) is not allowing any alias on the Delete object. Like for example I cannot say
DELETE org.hibernate.somepackage.someclass class where class.property = somevalue
instead I need to write it as
DELETE org.hibernate.somepackage.someclass where property = somevalue
When I use the first case, I get the Error "Unexpected Token". It doesn't work even if I use 'As class' for giving an alias.
I dont know whether this has been done purposefully or it is a bug, This creates a limitation that we cannot use a reference of the external objects when we try to delete them through a further selects like...
I cannot use it in this scenario...
DELETE org.hibernate.somepackage.someclass class where exists (select anotherObject newObj where newObj.property = class.property)
For doing the above delete operation I need to follow this round about way...
DELETE org.hibernate.somepackage.someclass where property in (select property from org.hibernate.somepackage.someclass class where exists (select anotherObject newObj where newObj.property = class.property))
Does any one has any better solution than this?
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: