[hibernate-issues] [JIRA] (HHH-14017) Adding PK proxy using field access to non-pk mapped collection results in NULL constraint violation

Christian Beikov (JIRA) jira at hibernate.atlassian.net
Tue May 12 16:00:04 EDT 2020


Christian Beikov ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A0222998d-a0c8-4789-91ec-6a92d10dfb9a ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiN2ZjY2MxOTY5OGNjNDcyY2IxYTEzMDAzNDAzZmQ4ZDgiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14017?atlOrigin=eyJpIjoiN2ZjY2MxOTY5OGNjNDcyY2IxYTEzMDAzNDAzZmQ4ZDgiLCJwIjoiaiJ9 ) HHH-14017 ( https://hibernate.atlassian.net/browse/HHH-14017?atlOrigin=eyJpIjoiN2ZjY2MxOTY5OGNjNDcyY2IxYTEzMDAzNDAzZmQ4ZDgiLCJwIjoiaiJ9 ) Adding PK proxy using field access to non-pk mapped collection results in NULL constraint violation ( https://hibernate.atlassian.net/browse/HHH-14017?atlOrigin=eyJpIjoiN2ZjY2MxOTY5OGNjNDcyY2IxYTEzMDAzNDAzZmQ4ZDgiLCJwIjoiaiJ9 )

Issue Type: Bug Affects Versions: 5.4.14 Assignee: Unassigned Components: hibernate-core Created: 12/May/2020 13:00 PM Priority: Major Reporter: Christian Beikov ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A0222998d-a0c8-4789-91ec-6a92d10dfb9a )

A simple model that maps a collection through a unique column

@Entity
@Table(name = "base_object" )
public class BaseObject implements Serializable {
   @Id
   @Column(name = "id" )
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Integer id;
   @Column(name = "name" , nullable = false , unique = true )
   private String name;
   @ManyToMany
   @JoinTable(
           name = "related_objects" ,
           joinColumns = @JoinColumn(name = "base_name" , referencedColumnName = "name" ),
           inverseJoinColumns = @JoinColumn(name = "related_name" , referencedColumnName = "name" )
   )
   private Set<RelatedObject> related = new HashSet<>();
}

@Entity
@Table(name = "related_object" )
public class RelatedObject {
   @Id
   @Column(name = "id" )
   @GeneratedValue(strategy = GenerationType.AUTO)
   private Integer id;
   @Column(name = "name" , nullable = false , unique = true )
   private String name;
}

When trying to add a RelatedObject reference to the collection, the flushing fails with a NULL constraint violation, although the proxy is lazily initialized.

       BaseObject b = entityManager.find(BaseObject.class, bId);
       RelatedObject r = entityManager.getReference(RelatedObject.class, rId);
       b.getRelated().add(r);
       entityManager.flush();

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

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#100126- sha1:dd08494 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200512/8f365451/attachment.html 


More information about the hibernate-issues mailing list