Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
When updating an ElementCollection does it trigger the @PostUpdate of the containing object?

I have an @ElementCollection Map<User, Long> permissions in a class.

    @ElementCollection
    @CollectionTable(name = "als_permission", joinColumns = @JoinColumn(name = "File"))
    @MapKeyJoinColumn(name = "User")
    @Column(name = "Permission")
    @JsonIgnore
    private Map<User, Integer> permissions = new HashMap<>();

I made some changes on that collection only, and invoke repo.save(entity). I see the record does get updated, but my @PostUpdate handler which is defined in @EntityListeners does not appear to be called.

Is there something I have to put to indicate it? I am thinking I may need to have some sort of cascade somewhere.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Short Answer: No.

I had the same issue came to the conclusion that this is not possible at the moment. Mainly because intended or not implemented yet, see: https://github.com/eclipse-ee4j/jpa-api/issues/167

For the testing I created a repository to find any event I could consumer for the given purpose: https://github.com/HannesRakete/so-jpa-element-collection-events

Workaround 1

Add a @Version for optimistic locking on the parent entity.

Workaround 2

Migrate to another association-type, see https://thorben-janssen.com/hibernate-tips-query-elementcollection/

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda