Hibernate HQL uninstall request

I need information, but I haven't found how to do it.

I have two tables:

  • Remesas
|codigo_prod|  nombre   |codigo_proveedor|
-----------------------------------------
|    1001   | product1  |     EST        |
|    1002   | product2  |     ASM        |

- Proveedores 

|codigo_proveedor|  mail         |
----------------------------------
|    EST        | pro@mail.com  |
|    ASM        | pro2@mail.com |  
|    DAM        | pro3@mail.com |

      

I need to remove from Proveedores a line that does not have codigo_proveedor on Remesas, in this case remove the DAM so that it is not on Remesas.

Thank!

0


source to share


2 answers


try this:

    Session s= HibernateUtil.getSession();
    s.beginTransaction();
    s.CreateSQLQuery("delete Proveedores where codigo_proveedor not in 
                      (select codigo_proveedor from Remesas)");
    s.getTransaction().commit();

      



I know this for Java!

0


source


How about this?



    delete Proveedores pr  where pr.codigo_proveedor not in 
                      (select re.codigo_proveedor from Remesas re)

      

+1


source







All Articles