workaround querydsl/querydsl/issues/2190

This commit is contained in:
f43nd1r 2019-12-06 19:12:42 +01:00
parent 499878544e
commit 0a83704f19
2 changed files with 8 additions and 13 deletions

View file

@ -17,7 +17,7 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<vaadin.version>14.0.14</vaadin.version>
<querydsl.version>4.2.1</querydsl.version>
<querydsl.version>4.2.2</querydsl.version>
<drivers.dir>${project.basedir}/drivers</drivers.dir>
<drivers.downloader.phase>pre-integration-test</drivers.downloader.phase>
<docker.image.prefix>f43nd1r</docker.image.prefix>

View file

@ -16,15 +16,7 @@
package com.faendir.acra.service;
import com.faendir.acra.dataprovider.QueryDslDataProvider;
import com.faendir.acra.model.App;
import com.faendir.acra.model.Attachment;
import com.faendir.acra.model.Bug;
import com.faendir.acra.model.MailSettings;
import com.faendir.acra.model.QApp;
import com.faendir.acra.model.Report;
import com.faendir.acra.model.Stacktrace;
import com.faendir.acra.model.User;
import com.faendir.acra.model.Version;
import com.faendir.acra.model.*;
import com.faendir.acra.model.view.Queries;
import com.faendir.acra.model.view.VApp;
import com.faendir.acra.model.view.VBug;
@ -35,6 +27,7 @@ import com.querydsl.core.types.Expression;
import com.querydsl.core.types.Predicate;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.ComparableExpressionBase;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPADeleteClause;
import com.querydsl.jpa.impl.JPAQuery;
import org.acra.ReportField;
@ -344,8 +337,9 @@ public class DataService implements Serializable {
@Transactional
@PreAuthorize("T(com.faendir.acra.security.SecurityUtils).hasPermission(#app, T(com.faendir.acra.model.Permission$Level).EDIT)")
public void deleteReportsOlderThanDays(@NonNull App app, @NonNull int days) {
new JPADeleteClause(entityManager, report).where(report.stacktrace.bug.app.eq(app).and(report.date.before(ZonedDateTime.now().minus(days, ChronoUnit.DAYS))));
public void deleteReportsOlderThanDays(@NonNull App app, int days) {
new JPADeleteClause(entityManager, report).where(report.stacktrace.in(JPAExpressions.select(stacktrace1).from(stacktrace1).where(stacktrace1.bug.app.eq(app)))
.and(report.date.before(ZonedDateTime.now().minus(days, ChronoUnit.DAYS)))).execute();
entityManager.flush();
applicationEventPublisher.publishEvent(new ReportsDeleteEvent(this));
}
@ -353,7 +347,8 @@ public class DataService implements Serializable {
@Transactional
@PreAuthorize("T(com.faendir.acra.security.SecurityUtils).hasPermission(#app, T(com.faendir.acra.model.Permission$Level).EDIT)")
public void deleteReportsBeforeVersion(@NonNull App app, int versionCode) {
new JPADeleteClause(entityManager, report).where(report.stacktrace.bug.app.eq(app).and(report.stacktrace.version.code.lt(versionCode)));
new JPADeleteClause(entityManager, report).where(report.stacktrace.in(JPAExpressions.select(stacktrace1).from(stacktrace1).where(stacktrace1.bug.app.eq(app)
.and(stacktrace1.version.code.lt(versionCode))))).execute();
entityManager.flush();
applicationEventPublisher.publishEvent(new ReportsDeleteEvent(this));
}