Hello,
thanks for your reply.
The SQL generated by hibernate is the following: select this_.ID as ID0_2_, this_1_.VERSION as VERSION0_2_, this_1_.CREATOR_ID as CREATOR3_0_2_, this_1_.S_ASSIGNEE as S4_0_2_, this_1_.S_OBJECT_TYPE as S5_0_2_, this_.S_OBJECT_TYPE as S2_1_2_, this_.NAME as NAME1_2_, this_.COMMENT as COMMEN T1_2_, this_.AMOUNT as AMOUNT1_2_, this_.CREATOR_ID as CREATOR6_1_2_, cr1_.ID as ID2_0_, cr1_.VERSION as VERSION2_0_, cr1_.S_OBJECT_TYPE as S3_2_0_, cr1_.CREATO R_ID as CREATOR4_2_0_, cr1_.USER_NAME as USER5_2_0_, cr1_.ID as ID2_1_, cr1_.VER SION as VERSION2_1_, cr1_.S_OBJECT_TYPE as S3_2_1_, cr1_.CREATOR_ID as CREATOR4_ 2_1_, cr1_.USER_NAME as USER5_2_1_ from DEAL this_ inner join TRACEABLE this_1_ on this_.ID=this_1_.ID inner join USER cr1_ on this_1_.CREATOR_ID=cr1_.ID inner join USER cr1_ on this_.CREATOR_ID=cr1_.ID where cr1_.USER_NAME=? order by this_ .ID desc
My Java code is in fact the implementation of a hook method in a Java framework. I give here the implementtaion of this method:
public void refineCriteria(EnhancedDetachedCriteria criteria, IQueryComponent queryComponent, Map<String, Object> context){
IApplicationSession session = getBackendController(context).getApplicationSession(); Boolean hasRole = SecurityHelper.isSubjectGranted( session.getSubject(), new roleHolder(role) );
if (hasRole && (queryComponent.getQueryContract().getName().contains(businessObject))){ criteria.createAlias("creator","cr",CriteriaSpecification.LEFT_JOIN).add(Restrictions.eq("cr.userName", session.getPrincipal().getName())).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
} }
|