• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Hibernate HQL Delete

 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • 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 ]
 
Edvins Reisons
Ranch Hand
Posts: 364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you seen the examples here?
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Hasn't anyone made the same experience like I did
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic