• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Batch Delete using Hibernate Querry?  RSS feed

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There, I am using this in my Configuration file
--> org.hibernate.hql.classic.ClassicQueryTranslatorFactory
I got a scenario where I need to execute delete * from Alerts where userid=?
By using above Factory class I was unable to execute this querry, it keep says querry should start with from or select.

If I replace this Factory with org.hibernate.hql.ast.ASTQueryTranslatorFactory, then this delete executes fine but my other from or select wont run they will start throwing exceptions.

**I dont want to use 2 different configuration file withing the same application..!

I got big confusion aroung this Factory class, which one is best to use and which one allow me to execute all the types of queries?
Thanks in Advance, VIJAY
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ASTQueryTranslatorFactory is the newer and more robust class. It should support Hibernate 2 HQL syntax (but not Hibernate 1 syntax). What exceptions do you see?
[ October 09, 2008: Message edited by: Paul Sturrock ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not an hibernate expert and I don't use it that often, but I never had your issues with it. You can probably do what you want using all those factories, I personally never had to think about it.

Usually people who use Hibernate don't write "plain SQL" queries. There are many tutorials on the Web about Hibernate and following their approach will probably help you resolve your specific issues faster.
 
Vijay Gadde
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that reply javascript:%20x()

But still I was unable to run batch delete. If I need to delete a set of alerts for an User first I need to run select query to select all the alerts for a particular user and then using loop i need to fetch each object and on selecting each object I need to delete them javascript:%20x() I know this is not the right way of doing this

Really apritiated for good example code on how to execute batch delete from a table.Thanks,VIJAY GADE
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!