0

Can i make a update in hibernate like this

    entityManager.createQuery("update test set  ... " +
            " where prop = :prop ")
            ....
            .setParameter("prop ", prop )
            .executeUpdate();

where prop is a field annotated by mappedBy

Hayi
  • 6,972
  • 26
  • 80
  • 139

1 Answers1

1

You must have a join to association to use it in the where clause. But Hibernate doesn't allow use joins with an update request. You should use a subquery. Please, see this.

Community
  • 1
  • 1
v.ladynev
  • 19,275
  • 8
  • 46
  • 67
  • 1
    @Youssef You are welcome. If you want to see some interesting techniques using Hibernate see [this](https://www.livecoding.tv/ladynev/). – v.ladynev Oct 20 '15 at 09:32