package com.hongsoft.res.database;
public class ResQuery {
//user
public static final String LOAD_USER_BY_ID=
"SELECT u FROM User as u WHERE u.id=?";
public static final String LOAD_USER_BY_LOGIN_NAME=
"SELECT u FROM User as u WHERE u.loginName=?";
//orgUnit
public static final String LOAD_ORG_BY_ID=
"SELECT o FROM OrgUnit as o WHERE o.id=?";
public static final String LOAND_ROLE_BY_NAME=
"SELECT o FROM OrgUnit as o WHERE o.name=?";
//resObjectRela
public static final String LOAD_RELATION_BY_ID=
"SELECT r FROM ResObjectRela as r WHERE r.id.parent_id=?";
public static final String LOAD_ORG_BY_USERID=
"SELECT r FROM ResObjectRela as r WHERE r.id.child_id=?";
//resObject
public static final String LOAD_ORGUNIT_BY_ID_FROM_RESOBJECT=
"SELECT r FROM ResObject as r WHERE r.orgUnit.id=?";
public static final String LOAD_USER_BY_ID_FROM_RESOBJECT=
"SELECT r FROM ResObject as r WHERE r.user.id=?";
public static final String LOAD_ROLE_BY_ID_FROM_RESOBJECT=
"SELECT r FROM ResObject as r WHERE r.role.id=?";
public static final String GET_OBJECT_TYPE_BY_ID=
"SELECT r FROM ResObject as r WHERE r.id=?";
public static final String CHECK_ORG_NAME_UNIQUE=
"SELECT o FROM OrgUnit as o,ResObjectRela as r WHERE r.id.parent_id=:parentID and o.name=:name and r.id.child_id=o.id and o.is_deleted=0";
public static final String THERE_IS_CHILD_ORG=
"SELECT o FROM ResObject as o,ResObjectRela as r WHERE r.id.parent_id=:parentID and o.type=:type and r.id.child_id=o.id and o.orgUnit.is_deleted=0";
public static final String THERE_IS_CHILD=
"SELECT o FROM ResObject as o,ResObjectRela as r WHERE r.id.parent_id=:parentID and r.id.child_id=o.id and o.orgUnit.is_deleted=0";
//role
public static final String LOAD_ROLE_BY_ID=
"SELECT r FROM Role as r WHERE r.id=?";
public static final String LOAD_ROLE_BY_NAME=
"SELECT r FROM Role as r WHERE r.name=?";
//privilege
public static final String LOAD_PRIVILIGE=
"SELECT p FROM ResPrivilege as p WHERE p.resID=?";
public static final String LOAD_ALL_PRIVILEGE_TYPE=
"SELECT t FROM PrivilegeType as t";
}