Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
Why hibernate generates cross join on delete?

I'm using PostgreSQL 9.6 with Hibernate 5.2.10 and have 3 entities:

@Entity  
@Table(name = "entity1")
public class Entity1 {
    @Id
    private long id;

    @ManyToOne
    @JoinColumn(name = "entity2_id")
    private Table2 table2;
}

@Entity  
@Table(name = "entity2")  
public class Entity2 {
    @Id
    private long id;

    @ManyToOne
    @JoinColumn(name = "entity3_id")
    private Table3 table3;
}

@Entity  
@Table(name = "entity3")  
public class Entity3 {
    @Id
    private long id;
}

I need to all delete the occurencies of Entity1 when it joins Entity2 filtering by Entity3, like this:

em.createQuery("delete from Entity1 e where e.entity2.entity3 = :entity3")

And Hibernate generates the following SQL:

delete from entity1 cross join entity2 entity2_ where entity3_id=?

The problem is that PostgreSQL does not recognized the cross join and I didn't find any other way to do this (other than using native query).

PS: in the database all the tables have foreign keys.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Now I found that it's not possible to use joins in delete queries (actually a was migrating from EclipseLink to Hibernate and on EclipseLink it worked, just on Hibernate it doesn't).
Hibernate Exception on MySQL Cross Join Query

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!