mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 10:17:43 +08:00
Get rid of default implicit conversion of JPQL query parameters #744
Compatibility with cuba.implicitConversionOfJpqlParams = true
This commit is contained in:
parent
e6c43a468e
commit
c5051f4800
@ -667,8 +667,8 @@ public class UserManagementServiceBean implements UserManagementService {
|
||||
}
|
||||
}
|
||||
|
||||
TypedQuery<Group> query = em.createQuery("select g from sec$Group g where g.parent = :group", Group.class);
|
||||
query.setParameter("group", group);
|
||||
TypedQuery<Group> query = em.createQuery("select g from sec$Group g where g.parent.id = :groupId", Group.class);
|
||||
query.setParameter("groupId", group.getId());
|
||||
|
||||
List<Group> subGroups = query.getResultList();
|
||||
if (subGroups != null && subGroups.size() > 0) {
|
||||
|
@ -115,14 +115,14 @@ public class UserSettingServiceBean implements UserSettingService {
|
||||
try (Transaction tx = persistence.createTransaction()) {
|
||||
EntityManager em = persistence.getEntityManager();
|
||||
|
||||
Query deleteSettingsQuery = em.createQuery("delete from sec$UserSetting s where s.user = ?1");
|
||||
deleteSettingsQuery.setParameter(1, toUser);
|
||||
Query deleteSettingsQuery = em.createQuery("delete from sec$UserSetting s where s.user.id = ?1");
|
||||
deleteSettingsQuery.setParameter(1, toUser.getId());
|
||||
deleteSettingsQuery.executeUpdate();
|
||||
tx.commitRetaining();
|
||||
em = persistence.getEntityManager();
|
||||
|
||||
TypedQuery<UserSetting> q = em.createQuery("select s from sec$UserSetting s where s.user = ?1", UserSetting.class);
|
||||
q.setParameter(1, fromUser);
|
||||
TypedQuery<UserSetting> q = em.createQuery("select s from sec$UserSetting s where s.user.id = ?1", UserSetting.class);
|
||||
q.setParameter(1, fromUser.getId());
|
||||
List<UserSetting> fromUserSettings = q.getResultList();
|
||||
|
||||
for (UserSetting currSetting : fromUserSettings) {
|
||||
@ -209,9 +209,9 @@ public class UserSettingServiceBean implements UserSettingService {
|
||||
Query delete = em.createQuery("delete from sec$Presentation p where p.user.id=?1");
|
||||
delete.setParameter(1, toUser);
|
||||
delete.executeUpdate();
|
||||
TypedQuery<Presentation> selectQuery = em.createQuery("select p from sec$Presentation p where p.user = ?1",
|
||||
TypedQuery<Presentation> selectQuery = em.createQuery("select p from sec$Presentation p where p.user.id = ?1",
|
||||
Presentation.class);
|
||||
selectQuery.setParameter(1, fromUser);
|
||||
selectQuery.setParameter(1, fromUser.getId());
|
||||
List<Presentation> presentations = selectQuery.getResultList();
|
||||
for (Presentation presentation : presentations) {
|
||||
Presentation newPresentation = metadata.create(Presentation.class);
|
||||
@ -235,18 +235,18 @@ public class UserSettingServiceBean implements UserSettingService {
|
||||
try {
|
||||
em.setSoftDeletion(false);
|
||||
Query deleteSettingsQuery = em.createQuery(
|
||||
String.format("delete from %s s where s.user = ?1", effectiveMetaClass.getName())
|
||||
String.format("delete from %s s where s.user.id = ?1", effectiveMetaClass.getName())
|
||||
);
|
||||
|
||||
deleteSettingsQuery.setParameter(1, toUser);
|
||||
deleteSettingsQuery.setParameter(1, toUser.getId());
|
||||
deleteSettingsQuery.executeUpdate();
|
||||
} finally {
|
||||
em.setSoftDeletion(true);
|
||||
}
|
||||
TypedQuery<SearchFolder> q = em.createQuery(
|
||||
String.format("select s from %s s where s.user = ?1", effectiveMetaClass.getName()),
|
||||
String.format("select s from %s s where s.user.id = ?1", effectiveMetaClass.getName()),
|
||||
SearchFolder.class);
|
||||
q.setParameter(1, fromUser);
|
||||
q.setParameter(1, fromUser.getId());
|
||||
|
||||
List<SearchFolder> fromUserFolders = q.getResultList();
|
||||
Map<SearchFolder, SearchFolder> copiedFolders = new HashMap<>();
|
||||
@ -321,18 +321,18 @@ public class UserSettingServiceBean implements UserSettingService {
|
||||
try {
|
||||
em.setSoftDeletion(false);
|
||||
Query deleteFiltersQuery = em.createQuery(
|
||||
String.format("delete from %s f where f.user = ?1", effectiveMetaClass.getName())
|
||||
String.format("delete from %s f where f.user.id = ?1", effectiveMetaClass.getName())
|
||||
);
|
||||
deleteFiltersQuery.setParameter(1, toUser);
|
||||
deleteFiltersQuery.setParameter(1, toUser.getId());
|
||||
deleteFiltersQuery.executeUpdate();
|
||||
} finally {
|
||||
em.setSoftDeletion(true);
|
||||
}
|
||||
|
||||
TypedQuery<FilterEntity> q = em.createQuery(
|
||||
String.format("select f from %s f where f.user = ?1", effectiveMetaClass.getName()),
|
||||
String.format("select f from %s f where f.user.id = ?1", effectiveMetaClass.getName()),
|
||||
FilterEntity.class);
|
||||
q.setParameter(1, fromUser);
|
||||
q.setParameter(1, fromUser.getId());
|
||||
List<FilterEntity> fromUserFilters = q.getResultList();
|
||||
|
||||
for (FilterEntity filter : fromUserFilters) {
|
||||
|
@ -296,11 +296,11 @@ public class AuthenticationManagerBean implements AuthenticationManager {
|
||||
TypedQuery<User> query = em.createQuery(
|
||||
"select su from sec$User su where " +
|
||||
"su in (select s.substitutedUser from sec$User u join u.substitutions s " +
|
||||
"where u = ?1 and s.substitutedUser = ?2)",
|
||||
"where u.id = ?1 and s.substitutedUser.id = ?2)",
|
||||
User.class
|
||||
);
|
||||
query.setParameter(1, currentSession.getUser());
|
||||
query.setParameter(2, substitutedUser);
|
||||
query.setParameter(1, currentSession.getUser().getId());
|
||||
query.setParameter(2, substitutedUser.getId());
|
||||
List<User> list = query.getResultList();
|
||||
if (list.isEmpty()) {
|
||||
throw new NoResultException("User not found");
|
||||
|
@ -99,8 +99,8 @@ public class GroupEntityListener implements
|
||||
|
||||
TypedQuery<GroupHierarchy> q = em.createQuery(
|
||||
"select h from sec$GroupHierarchy h join fetch h.group " +
|
||||
"where h.parent = ?1", GroupHierarchy.class);
|
||||
q.setParameter(1, entity);
|
||||
"where h.parent.id = ?1", GroupHierarchy.class);
|
||||
q.setParameter(1, entity.getId());
|
||||
List<GroupHierarchy> list = q.getResultList();
|
||||
for (GroupHierarchy hierarchy : list) {
|
||||
Group dependentGroup = hierarchy.getGroup();
|
||||
|
@ -178,8 +178,8 @@ public class UserSessionManager {
|
||||
protected void compileConstraints(UserSession session, Group group) {
|
||||
EntityManager em = persistence.getEntityManager();
|
||||
TypedQuery<Constraint> q = em.createQuery("select c from sec$GroupHierarchy h join h.parent.constraints c " +
|
||||
"where h.group = ?1", Constraint.class);
|
||||
q.setParameter(1, group);
|
||||
"where h.group.id = ?1", Constraint.class);
|
||||
q.setParameter(1, group.getId());
|
||||
List<Constraint> constraints = q.getResultList();
|
||||
List<Constraint> list = new ArrayList<>(constraints);
|
||||
list.addAll(group.getConstraints());
|
||||
@ -195,8 +195,8 @@ public class UserSessionManager {
|
||||
|
||||
EntityManager em = persistence.getEntityManager();
|
||||
TypedQuery<SessionAttribute> q = em.createQuery("select a from sec$GroupHierarchy h join h.parent.sessionAttributes a " +
|
||||
"where h.group = ?1 order by h.level desc", SessionAttribute.class);
|
||||
q.setParameter(1, group);
|
||||
"where h.group.id = ?1 order by h.level desc", SessionAttribute.class);
|
||||
q.setParameter(1, group.getId());
|
||||
List<SessionAttribute> attributes = q.getResultList();
|
||||
list.addAll(attributes);
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
</groupDatasource>
|
||||
|
||||
<collectionDatasource id="loggedAttrDs" class="com.haulmont.cuba.security.entity.LoggedAttribute" view="_local">
|
||||
<query>select a from sec$LoggedAttribute a where a.entity = :ds$loggedEntityDs</query>
|
||||
<query>select a from sec$LoggedAttribute a where a.entity.id = :ds$loggedEntityDs.id</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource id="usersDs"
|
||||
@ -51,7 +51,7 @@
|
||||
<and>
|
||||
<c>e.type = :component$changeTypeField</c>
|
||||
<c>e.entity = :component$filterEntityNameField</c>
|
||||
<c>e.user = :component$userField</c>
|
||||
<c>e.user.id = :component$userField.id</c>
|
||||
<c>e.eventTs >= :component$fromDateField</c>
|
||||
<c>e.eventTs <= :component$tillDateField</c>
|
||||
<c>e.entityRef.entityId = :custom$entityId</c>
|
||||
|
@ -25,7 +25,7 @@
|
||||
<collectionDatasource id="executionsDs" class="com.haulmont.cuba.core.entity.ScheduledExecution" view="_local">
|
||||
<query><![CDATA[
|
||||
select e from sys$ScheduledExecution e
|
||||
where e.task = :param$task
|
||||
where e.task.id = :param$task.id
|
||||
<#if (component$finishedField?has_content && component$finishedField == true)>and e.finishTime is not null</#if>
|
||||
order by e.startTime desc
|
||||
]]>
|
||||
|
@ -26,7 +26,7 @@
|
||||
class="com.haulmont.cuba.core.entity.SendingAttachment"
|
||||
view="sendingAttachment.browse">
|
||||
<query>
|
||||
<![CDATA[select sa from sys$SendingAttachment sa where sa.message = :param$message]]>
|
||||
<![CDATA[select sa from sys$SendingAttachment sa where sa.message.id = :param$message.id]]>
|
||||
</query>
|
||||
</collectionDatasource>
|
||||
</dsContext>
|
||||
|
@ -40,21 +40,21 @@
|
||||
class="com.haulmont.cuba.security.entity.User"
|
||||
view="group.browse"
|
||||
maxResults="50">
|
||||
<query>select u from sec$User u where u.group = :ds$groupsDs</query>
|
||||
<query>select u from sec$User u where u.group.id = :ds$groupsDs.id</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource
|
||||
id="constraintsDs"
|
||||
class="com.haulmont.cuba.security.entity.Constraint"
|
||||
view="group.browse">
|
||||
<query>select c from sec$Constraint c where c.group = :ds$groupsDs</query>
|
||||
<query>select c from sec$Constraint c where c.group.id = :ds$groupsDs.id</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource
|
||||
id="attributesDs"
|
||||
class="com.haulmont.cuba.security.entity.SessionAttribute"
|
||||
view="_local">
|
||||
<query>select a from sec$SessionAttribute a where a.group = :ds$groupsDs</query>
|
||||
<query>select a from sec$SessionAttribute a where a.group.id = :ds$groupsDs.id</query>
|
||||
</collectionDatasource>
|
||||
</dsContext>
|
||||
|
||||
|
@ -196,8 +196,8 @@ public class RoleBrowser extends AbstractLookup {
|
||||
for (User user : items) {
|
||||
LoadContext<UserRole> ctx = LoadContext.create(UserRole.class)
|
||||
.setView("user.edit")
|
||||
.setQuery(new LoadContext.Query("select ur from sec$UserRole ur where ur.user = :user")
|
||||
.setParameter("user", user)
|
||||
.setQuery(new LoadContext.Query("select ur from sec$UserRole ur where ur.user.id = :userId")
|
||||
.setParameter("userId", user.getId())
|
||||
);
|
||||
|
||||
List<UserRole> userRoles = dataManager.loadList(ctx);
|
||||
|
@ -29,7 +29,7 @@
|
||||
class="com.haulmont.cuba.security.entity.Permission"
|
||||
view="role.edit"
|
||||
datasourceClass="com.haulmont.cuba.gui.app.security.ds.RestorablePermissionDatasource">
|
||||
<query>select p from sec$Permission p where p.role = :ds$roleDs and p.type = 30</query>
|
||||
<query>select p from sec$Permission p where p.role.id = :ds$roleDs.id and p.type = 30</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource id="attributeTargetsDs"
|
||||
|
@ -29,7 +29,7 @@
|
||||
class="com.haulmont.cuba.security.entity.Permission"
|
||||
view="role.edit"
|
||||
datasourceClass="com.haulmont.cuba.gui.app.security.ds.RestorablePermissionDatasource">
|
||||
<query>select p from sec$Permission p where p.role = :ds$roleDs and p.type = 20</query>
|
||||
<query>select p from sec$Permission p where p.role.id = :ds$roleDs.id and p.type = 20</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource id="entityTargetsDs"
|
||||
|
@ -29,7 +29,7 @@
|
||||
class="com.haulmont.cuba.security.entity.Permission"
|
||||
view="role.edit"
|
||||
datasourceClass="com.haulmont.cuba.gui.app.security.ds.RestorablePermissionDatasource">
|
||||
<query>select p from sec$Permission p where p.role.id = :ds$roleDs and p.type = 10</query>
|
||||
<query>select p from sec$Permission p where p.role.id = :ds$roleDs.id and p.type = 10</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource id="screenPermissionsTreeDs"
|
||||
|
@ -29,7 +29,7 @@
|
||||
class="com.haulmont.cuba.security.entity.Permission"
|
||||
view="role.edit"
|
||||
datasourceClass="com.haulmont.cuba.gui.app.security.ds.RestorablePermissionDatasource">
|
||||
<query>select p from sec$Permission p where p.role = :ds$roleDs and p.type = 40</query>
|
||||
<query>select p from sec$Permission p where p.role.id = :ds$roleDs.id and p.type = 40</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<collectionDatasource id="specificPermissionsTreeDs"
|
||||
|
@ -29,7 +29,7 @@
|
||||
class="com.haulmont.cuba.security.entity.Permission"
|
||||
view="role.edit"
|
||||
datasourceClass="com.haulmont.cuba.gui.app.security.ds.RestorablePermissionDatasource">
|
||||
<query>select p from sec$Permission p where p.role = :ds$roleDs and p.type = 50</query>
|
||||
<query>select p from sec$Permission p where p.role.id = :ds$roleDs.id and p.type = 50</query>
|
||||
</collectionDatasource>
|
||||
|
||||
<groupDatasource id="uiPermissionTargetsDs"
|
||||
|
Loading…
Reference in New Issue
Block a user