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