[hibernate-issues] [JIRA] (HHH-14151) SingularAttribute.isOptional() does not honour javax.validation.constraints.NotNull

Filip Procházka (JIRA) jira at hibernate.atlassian.net
Wed Aug 12 13:32:25 EDT 2020


Filip Procházka ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ab26fa6ed-1884-4c13-a7c1-71f3d38b1eb3 ) *updated* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTdhNjU2N2YwMzRiNGRhMWEyMzg5ZGMzMjA1OWQyZjkiLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-14151?atlOrigin=eyJpIjoiYTdhNjU2N2YwMzRiNGRhMWEyMzg5ZGMzMjA1OWQyZjkiLCJwIjoiaiJ9 ) HHH-14151 ( https://hibernate.atlassian.net/browse/HHH-14151?atlOrigin=eyJpIjoiYTdhNjU2N2YwMzRiNGRhMWEyMzg5ZGMzMjA1OWQyZjkiLCJwIjoiaiJ9 ) SingularAttribute.isOptional() does not honour javax.validation.constraints.NotNull ( https://hibernate.atlassian.net/browse/HHH-14151?atlOrigin=eyJpIjoiYTdhNjU2N2YwMzRiNGRhMWEyMzg5ZGMzMjA1OWQyZjkiLCJwIjoiaiJ9 )

Change By: Filip Procházka ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Ab26fa6ed-1884-4c13-a7c1-71f3d38b1eb3 )

I've just upgraded Spring Boot, which upgraded Hibernate ORM from 5.4.12.Final to 5.4.18.Final

I have an association

{code:java}
@javax.persistence.ManyToOne(fetch = FetchType.LAZY)
@javax.validation.constraints.NotNull
private Product product;
{code}

I have logic that inspects metadata and collects nullable associations of an entity

{code:java}
List<Attribute<?, ?>> fields = new ArrayList<>();

fields.addAll(entityType.getSingularAttributes().stream()
.filter(singularAttribute -> singularAttribute.isAssociation()
&& singularAttribute.getType() instanceof EntityType
&& singularAttribute.isOptional())
.collect(Collectors.toList()));

return fields;
{code}

where `entityType` is `javax.persistence.metamodel.EntityType`

Previously, the `isOptional` honoured the `NotNull` constraint and returned false, not now it returns true which breaks my logic. I'm not yet sure if this is a miss-configuration by Spring Boot or by my application or if it's a bug in Hibernate, but with the upgrade this changed unexpectedly.

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

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#100144- sha1:57e1ab7 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200812/4a9915b8/attachment.html 


More information about the hibernate-issues mailing list