@@ -58,27 +58,21 @@ public SQLQueryString buildQuery(Query<?> query) {
5858 .append (" FROM `" )
5959 .append (repo .getInfo ().getTableName ())
6060 .append ('`' );
61- QueryGroup <? > where = query .getWhereGroup ();
61+ QueryGroup <Model > where = ( QueryGroup < Model >) query .getWhereGroup ();
6262 checkWithDeleted (repo , query .isWithDeleted (), where );
6363 if (query .shouldApplyAccessible ()) {
64- if (where .getQueryElements ().isEmpty ()) {
65- try {
66- where = (QueryGroup <Model >) accessibleAccessMethod .invoke (repo .getAccessible (), query , where , query .getAccessor ());
67- } catch (IllegalAccessException | InvocationTargetException e ) {
68- throw new ORMQueryException (e );
69- }
64+ QueryGroup <Model > accessChecks ;
65+ try {
66+ accessChecks = (QueryGroup <Model >) accessibleAccessMethod .invoke (repo .getAccessible (), query , new QueryGroup <>(), query .getAccessor ());
67+ } catch (IllegalAccessException | InvocationTargetException e ) {
68+ throw new ORMQueryException (e );
7069 }
71- QueryGroup <?> actualWhere = where ;
72- where = new QueryGroup <>()
73- .and (q -> (QueryGroup <Model >) actualWhere )
74- .and (q -> {
75- try {
76- return (QueryGroup <Model >) accessibleAccessMethod .invoke (repo .getAccessible (), query , q , query .getAccessor ());
77- } catch (IllegalAccessException | InvocationTargetException e ) {
78- throw new ORMQueryException (e );
79- }
80- });
81-
70+ QueryGroup <Model > actualWhere = where ;
71+ where = new QueryGroup <>();
72+ if (!actualWhere .getQueryElements ().isEmpty ())
73+ where .and (q -> actualWhere );
74+ if (!accessChecks .getQueryElements ().isEmpty ())
75+ where .and (q -> accessChecks );
8276 }
8377 if (!where .getQueryElements ().isEmpty ()) {
8478 SQLQueryString qs = convertGroup (repo .getInfo (), where );
0 commit comments