Blazebit / blaze-persistence

Rich Criteria API for JPA providers
https://persistence.blazebit.com
Apache License 2.0
741 stars 90 forks source link

PropertyNotFound exception when saving a new entity view to collection on a parent view #1503

Open dsarlo-viso opened 2 years ago

dsarlo-viso commented 2 years ago

Description

We are attempting to add a new entity view to a collection that is a child on another entity view. When trying to save the parent, we get a PropertyNotFound exception from hibernate.

org.hibernate.PropertyNotFoundException: Unable to locate property named org on com.visotrust.viso.domain.OrgDataTypeConfig
    at org.hibernate.type.ComponentType.getPropertyIndex(ComponentType.java:751)    at com.blazebit.persistence.integration.hibernate.base.HibernateJpaProvider.getJoinMappingPropertyNames(HibernateJpaProvider.java:1616)
    at com.blazebit.persistence.impl.CachingJpaProvider.getJoinMappingPropertyNames(CachingJpaProvider.java:402)

This is the current structure ClientProfileUpdateView -> Set<OrgDataTypeConfigUpdateView> -> DataTypeUpdateView -> OrgIdView getOrg(); If I save OrgDataTypeConfigUpdateView directly, DataType entity is persisted properly to the db, but as soon as I go a layer up, trying to save the ClientProfile after adding the new OrgDataTypeConfigUpdateView, everything blows up. Attached is a screenshot of where the ownerMapping is coming from. It is still set to orgDataTypeConfigs, when it should instead be orgDataTypeConfigs.dataType since that is where the org property exists.

Screen Shot 2022-06-13 at 12 01 51 PM

Potentially related to #1502

Expected behavior

When saving the parent entity view with the newly added DataTypeUpdateView, it should successfully save the new child entity to the db and link to the parent.

Actual behavior

org.hibernate.PropertyNotFoundException: Unable to locate property named org on com.visotrust.viso.domain.OrgDataTypeConfig
    at org.hibernate.type.ComponentType.getPropertyIndex(ComponentType.java:751)    at com.blazebit.persistence.integration.hibernate.base.HibernateJpaProvider.getJoinMappingPropertyNames(HibernateJpaProvider.java:1616)
    at com.blazebit.persistence.impl.CachingJpaProvider.getJoinMappingPropertyNames(CachingJpaProvider.java:402)

Steps to reproduce

Can try to create a reproducer if needed.

Environment

Version: 1.6.6 JPA-Provider: Hibernate 5.6.8.Final (Spring Data JPA 2.6.6) DBMS: PostgreSQL 13.3 Application Server: Spring Boot 2.6.6

beikov commented 2 years ago

Hey Dan, thanks for the detailed report. If you can create a reproducer for this, that would be really awesome.

dsarlo-viso commented 2 years ago

@beikov Awesome! I'll get on that when I have some down time next. Thanks!