Answer the question
In order to leave comments, you need to log in
Spring Data JPA - JPQL Update query?
I have a specific exercise as part of my homework in class at the university. This entity structure looks like this:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Parent {
...some fields...
}
@Entity
public class ChildA extends Parent {
...
}
@Entity
public class ChildB extends Parent {
...
}
public interface ParentRepository extends JpaRepository<Parent, Integer> {
void updateInBulk(Class<? extends Parent> clazz, int someParameter);
}
public interface ParentRepository extends JpaRepository<Parent, Integer> {
@Modifying
@Query("update :entity e set e.some_field = 'T' where e.other_field > :some_param")
void updateInBulk(@Param("entity") Class<? extends Parent> clazz, @Param("some_param") int someParam);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question