We're updating the issue view to help you get more done. 

Immutable entities can be updated via bulk update queries

Description

Assuming we have an @Immutable entity:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 @Entity(name = "Event") @Immutable public static class Event { @Id private Long id; @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_on") private Date createdOn = new Date(); @Column(name = "event_key") private String eventKey; @Column(name = "event_value") private String eventValue; public Event(Long id, String eventKey, String eventValue) { this.id = id; this.eventKey = eventKey; this.eventValue = eventValue; } private Event() { } public Long getId() { return id; } public Date getCreatedOn() { return createdOn; } public String getEventKey() { return eventKey; } public String getEventValue() { return eventValue; } }

All entity changes are prevented, but bulk update is still possible:

1 2 3 4 5 6 7 entityManager.createQuery( "update Event " + "set eventValue = :eventValue " + "where id = :id") .setParameter("eventValue", "10") .setParameter("id", 1L) .executeUpdate();

We should probably prevent these bulk update queries as well either by throwing an exception or logging a WARNING message and returning an empty result set.

Environment

None

Status

Assignee

Vlad Mihalcea

Reporter

Vlad Mihalcea

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major