Hayi
Hayi

Reputation: 6236

Update a field annotated mappedBy

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

Upvotes: 0

Views: 51

Answers (1)

v.ladynev
v.ladynev

Reputation: 19956

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.

Upvotes: 1

Related Questions