[hibernate-issues] [JIRA] (HHH-13898) BeanValidationListener not called for collection updates in ManyToMany relationships

Marek Šabo (JIRA) jira at hibernate.atlassian.net
Fri Mar 20 19:45:14 EDT 2020


Marek Šabo ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a39c88de8dc74376d64ea21 ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYjI3Y2M5OWU3Njc5NDdmZTk1ODExMjI5ZGMzNzg0ZTQiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13898?atlOrigin=eyJpIjoiYjI3Y2M5OWU3Njc5NDdmZTk1ODExMjI5ZGMzNzg0ZTQiLCJwIjoiaiJ9 ) HHH-13898 ( https://hibernate.atlassian.net/browse/HHH-13898?atlOrigin=eyJpIjoiYjI3Y2M5OWU3Njc5NDdmZTk1ODExMjI5ZGMzNzg0ZTQiLCJwIjoiaiJ9 ) BeanValidationListener not called for collection updates in ManyToMany relationships ( https://hibernate.atlassian.net/browse/HHH-13898?atlOrigin=eyJpIjoiYjI3Y2M5OWU3Njc5NDdmZTk1ODExMjI5ZGMzNzg0ZTQiLCJwIjoiaiJ9 )

Issue Type: Bug Affects Versions: 5.4.10 Assignee: Unassigned Components: hibernate-core Created: 20/Mar/2020 16:45 PM Priority: Major Reporter: Marek Šabo ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5a39c88de8dc74376d64ea21 )

I have a class User mapped with roles like this:

@Entity
@Table(name = "user" )
public class User extends BaseEntity< String > {

   @Id
   @Column(name = "id" , nullable = false , updatable = false )
   private String isid;

   @Column(name = "first_name" )
   private String firstName;

   @Column(name = "last_name" )
   private String lastName;

   @Size(min = 1, max = 2)
   @ManyToMany
   @JoinTable(name = "user_roles" ,
           joinColumns = @JoinColumn(name = "id" , referencedColumnName = "user_id" ,
                   nullable = false , insertable = false , updatable = false ),
           inverseJoinColumns = {
                   @JoinColumn(name = "id" , referencedColumnName = "role_id" ,
                           nullable = false , insertable = false , updatable = false ),
                   @JoinColumn(name = "role_type_id" , referencedColumnName = "role_type_id" ,
                           nullable = false , insertable = false , updatable = false )
           }
   )
   @WhereJoinTable(clause = "role_type_id = 7" )
   private List<Role> sevenRoles;

Works as expected for reads and inserts. However, if I try to insert third role into the collection (max size 2) it will persist instead of failing because *BeanValidationListener* is not bound to *CollectionUpdateAction*.
for comparison, if I simultaneously change the firstName/lastName, then the EntityUpdateAction is fired instead which has the *BeanValidationListener* bound and called during its preUpdate call.

( https://hibernate.atlassian.net/browse/HHH-13898#add-comment?atlOrigin=eyJpIjoiYjI3Y2M5OWU3Njc5NDdmZTk1ODExMjI5ZGMzNzg0ZTQiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13898#add-comment?atlOrigin=eyJpIjoiYjI3Y2M5OWU3Njc5NDdmZTk1ODExMjI5ZGMzNzg0ZTQiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100122- sha1:767d807 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200320/40abe4ec/attachment.html 


More information about the hibernate-issues mailing list