Questions tagged [hql-delete]

Questions related to deleting entities using HQL in hibernate, NHibernate and its derivatives.

Deleting entities with HQL (Hibernate Query Language) is possible in both Hibernate and NHibernate as an alternative to the common session.delete(entity). It has its very specific issues and limitations which are not known when using HQL for normal querying or session.delete(entity).

This tag marks questions specific to the deletion of entities using HQL in Hibernate or NHibernate or its derivatives.

14 questions
20
votes
4 answers

Hibernate HQL delete with and

Hibernate doesn't delete my row: public boolean deleteVote(Login user, int pid){ Session session = getSession(); try{ String hql = "delete from Vote where uid= :uid AND pid= :pid"; Query query =…
user1671980
  • 273
  • 1
  • 4
  • 10
6
votes
3 answers

Hibernate 4.1.11 hql delete query with where in list

I want to delete from a table some entries with specific ids. I want to know the syntax of this request delete from table where id in list_of_ids in hql.
Tdev John
  • 61
  • 1
  • 3
4
votes
5 answers

HQL delete associations from many to many mapping

I Have two entities CRImageType & CRVariable with a many to many relation as follows: CRImageType entity: @Entity @Table(name = "imageviewer_crimagetype") public class CRImageType implements Serializable { private static final long…
thanili
  • 777
  • 4
  • 26
  • 57
3
votes
1 answer

Difference between HQL delete query and session.delete()

I'm quite new to Hibernate and have a question. What is the difference between deleting an object by using an HQL query and deleting an object by using the delete(...) Method of the Session Class?
Patrick
  • 89
  • 2
  • 6
3
votes
3 answers

Why does this HQL delete fail, when an HQL select with same terms works?

Why does the following HQL query fail? string hql = @"delete MyLog log where log.UtcTimestamp < :threshold and log.Configuration.Application = :application"; session.CreateQuery(hql) …
Thomas Bratt
  • 48,038
  • 36
  • 121
  • 139
2
votes
1 answer

Remove items using HQL "delete from where is empty" clause

I have two entities within a relationship tag <-m:n-> software and I want to delete all softwares which are not links to tags anymore after deleting particular tag. I write the HQL query for that.. i use playframework my overridden Tag.delete()…
ses
  • 13,174
  • 31
  • 123
  • 226
2
votes
2 answers

hql query to delete records in two tables

My query is. Query query1 = session.createQuery( "DELETE Question, Answer FROM Question que LEFT JOIN Answer ans ON que.id=ans.questionId WHERE que.quiz_type_id=:qtypeid"); query1.setParameter("qtypeid", id); …
Keyur Bhanderi
  • 1,524
  • 1
  • 11
  • 17
2
votes
1 answer

Hibernate: HQL delete from embedded map

I want to delete entries from an embedded map. If the object CategoryTag is deleted, I want to execute a HQL query in an interceptor, which deletes the entries from a map: 'Product' model: @NotNull @ElementCollection @CollectionTable(name =…
Flo
  • 1,469
  • 1
  • 18
  • 27
1
vote
1 answer

HQL alias in delete query

I want to know hql analog for SQL: delete license from license, license_pool where license.license_pool_id = license_pool.license_pool_id and license.school_id = 13 and license_pool.program_id = 1 and license.staff_member_id is null
psylocybe
  • 23
  • 6
0
votes
2 answers

hibernate HQL delete query nullifies single column

I am working on spring hibernate application and trying to delete from a table using non-id many-to-one relationship based column. Entity classes are: @Entity public class Day { @id(name = "DAY_ID") dayId; @OneToMany(cascade =…
parbi
  • 533
  • 1
  • 10
  • 19
0
votes
1 answer

hibernate delete using hql

I have the following mapping in hibernate:
semantic-dev
  • 1,095
  • 3
  • 14
  • 27
0
votes
1 answer

How to delete using HQL?

I'm using this example: http://www.mkyong.com/hibernate/hibernate-query-examples-hql/ And trying to delete this way: String qhl = "delete from logs where dateTtime >= current_date - interval '1 month'"; Query query =…
Magno C
  • 1,922
  • 4
  • 28
  • 53
0
votes
1 answer

Hibernate: Column ambiguously defined error when execute HQL delete on an Entity with @SecondaryTable annotation

I have an Entity shown as below, there are two tables mapped by annotation @SecondaryTable. The PrimaryKey's names of two tables are both 'resource_id'. When I execute HQL delete AssetProjectProposalInfoEntity e where e.resourceId=:rid Column…
Rong.l
  • 338
  • 2
  • 13
0
votes
2 answers

Hibernate HQL delete query

Im looking for information but I didnt find how. I have two tables: Remesas |codigo_prod| nombre |codigo_proveedor| ----------------------------------------- | 1001 | product1 | EST | | 1002 | product2 | ASM …
user3360162