• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Hibernate HQL Delete

 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone of you experienced a problem with Hibernate's HQL Delete ability?

See the following example from the book Core J2EE Patterns:



Think you want to add a method removeLineItem(String[] whereClauseCriterias) with HQL. How would your HQL String looks like .

String hqlDelete = "delete from LineItem li where ..."
[ December 04, 2008: Message edited by: Darya Akbari ]
 
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you seen the examples here?
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I know these examples. Unfortunately these are all simple ones.

The pain starts when I go in my WHERE-Clause through relations. Think you would like to delete all LineItems that belong to an Order which belong to an Account.

When Hibernate translate this HQL into SQL it forget to set the right SQL/POJO alias for the right property.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A HQL Select works fine. But doing the same with an HQL Delete becomes a mess.

Unfortunately all Hibernate examples I've seen so far are easy ones. None of them show up a WHERE clause with relations for reaching other objects.
[ December 04, 2008: Message edited by: Darya Akbari ]
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hasn't anyone made the same experience like I did
 
ice is for people that are not already cool. Chill with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic