/** * Throws AccessException if the context user is not admin user and not owner of the UserXmlPreferences, meaning the * given userId must be the id of the context user. * * @param userId */ public UserXmlPreferencesDO getUserPreferencesByUserId(final Integer userId, final String key, final boolean checkAccess) { if (checkAccess == true) { checkAccess(userId); } final List<UserXmlPreferencesDO> list = emgrFactory.runInTrans((emgr) -> { return emgr.selectAttached(UserXmlPreferencesDO.class, "select u from UserXmlPreferencesDO u where u.user.id = :userid and u.key = :key", "userid", userId, "key", key); }); Validate.isTrue(list.size() <= 1); if (list.size() == 1) { return list.get(0); } else return null; }
/** * Throws AccessException if the context user is not admin user and not owner of the UserXmlPreferences, meaning the * given userId must be the id of the context user. * * @param userId */ @Transactional(readOnly = true, propagation = Propagation.SUPPORTS) public List<UserXmlPreferencesDO> getUserPreferencesByUserId(final Integer userId) { checkAccess(userId); return PfEmgrFactory.get().runInTrans((emgr) -> { return emgr.select(UserXmlPreferencesDO.class, "select u from UserXmlPreferencesDO u where u.user.id = :userid", "userid", userId); }); }