• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate HQL Delete query problem

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following are my entity classes:







HQL DELETE Query :


Hibernate: delete from sample_entity_b, sample_entity_a sea1_ where customEnum=?
17:19:12,770 ERROR JDBCExceptionReporter:101 - You have an error in your SQL syntax; check the manu
al that corresponds to your MySQL server version for the right syntax to use near
'sample_entity_a sea1_ where customEnum='LOCATION'' at line 1

**Note: I am passing CustomEnum.LOCATION as the parameter value to 'customEnumVal'

Can anybody please help in rectifying this query and making it work?

Thanks,
Jignesh
 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case anybody requires the solution this is the way I solved the problem.The syntax for delete as mentioned in problem was not valid.In batch delete queries only the related entities primary key should be specified in the WHERE clause of the desired query to be executed and not their nested properties.However using subselect(s) or subqueries you can resolve your problem.For example in my case I solved my purpose using the below query:


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic