-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Native SQL : DELETE doesn't take Alias, Possible Bug
PostPosted: Wed Apr 12, 2006 12:06 pm 
Newbie

Joined: Wed Mar 22, 2006 5:29 pm
Posts: 2
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.