The @SoftDelete join entity does not generate a delete condition

Entity

@Entity
@Table(name = "organization")
@SoftDelete(columnName = "is_deleted", converter = SoftDeleteConverter.class)
public class OrganizationEntity extends BaseEntity<String> {}
@Entity
@Table(name = "organization_member")
@SoftDelete(columnName = "is_deleted", converter = SoftDeleteConverter.class)
public class OrganizationMemberEntity extends BaseEntity<Long> {}

Query

//@formatter:off
TypedQuery<OrganizationMemberPO> query = entityManager.createQuery("SELECT om.id, om.userId, om.orgId,organization.name,organization.displayPath,om.primary FROM OrganizationMemberEntity om INNER JOIN OrganizationEntity organization ON organization.id = om.orgId WHERE om.userId =:userId", OrganizationMemberPO.class);
query.setParameter("userId", userId);
//@formatter:on
return query.getResultList();

Generate SQL:

select
            ome1_0.id_,
            ome1_0.user_id,
            ome1_0.org_id,
            oe1_0.name_,
            oe1_0.display_path,
            ome1_0.primary_ 
        from
            organization_member ome1_0 
        left join
            organization oe1_0 
                on oe1_0.id_=ome1_0.org_id 
        where
            ome1_0.user_id=? 
            and ome1_0.is_deleted=0

That’s a bug. Please try to create a reproducer with our test case template (https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) and if you are able to reproduce the issue, create a bug ticket in our issue tracker(https://hibernate.atlassian.net) and attach that reproducer.

Issues: [HHH-17511] - Hibernate JIRA

Replicate test: Repetition: https://hibernate.atlassian.net/browse/HHH-17511 by leshalv · Pull Request #339 · hibernate/hibernate-test-case-templates · GitHub

Can this version be fixed in hibernate6.4.1? Now that we have used the new hibernate soft delete feature, the iteration of the application is stuck here for now.

1 Like