Left Join with IS NULL condition

26 views
Skip to first unread message

Udhay Kumar

unread,
Apr 8, 2015, 5:56:36 PM4/8/15
to quer...@googlegroups.com
SELECT 
    p.idp.name
FROM
    permission p
        LEFT JOIN
    role_permission rp 
    ON rp.permission_id = p.id and rp.role_id=1 where rp.permission_id is null;

What should I put in .where in QueryDSL?

query.from(permission)
                              .leftJoin(permission.roles, role)
                              .on(role.id.eq(roleId))
                              .where(XXX)
                              .list(permission);

John Tims

unread,
Apr 8, 2015, 6:25:25 PM4/8/15
to quer...@googlegroups.com
You should be able to use role.id.isNull();

- John

Udhay Kumar

unread,
Apr 9, 2015, 2:30:12 PM4/9/15
to quer...@googlegroups.com
role.id denotes ROLE.ID 
as in Role.java I got:
 @ManyToMany
  private Set<Permission> permissions = new HashSet<Permission>();

I need to check for ROLE_PERMISSION.PERMISSION_ID IS NULL
However ROLE_PERMISSION here is a join table and I need not create an entity for this table.
Reply all
Reply to author
Forward
0 new messages