Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

250
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda