Skip to content

Commit 8421437

Browse files
BroadleafCommerce/QA#1512 - Since you want the absolute max of the table when detecting sequence generator corruption, ignore all filters like if records are archived or not
1 parent 693f402 commit 8421437

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

common/src/main/java/org/broadleafcommerce/common/persistence/SequenceGeneratorCorruptionDetection.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.commons.lang.StringUtils;
2424
import org.apache.commons.logging.Log;
2525
import org.apache.commons.logging.LogFactory;
26+
import org.broadleafcommerce.common.web.BroadleafRequestContext;
2627
import org.hibernate.SessionFactory;
2728
import org.hibernate.annotations.GenericGenerator;
2829
import org.hibernate.annotations.Parameter;
@@ -153,7 +154,16 @@ public void onApplicationEvent(ContextRefreshedEvent event) {
153154
sb.append(") from ");
154155
sb.append(mappedClass.getName());
155156
sb.append(" entity");
156-
List results = em.createQuery(sb.toString()).getResultList();
157+
158+
List results;
159+
BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
160+
try {
161+
context.setInternalIgnoreFilters(true);
162+
results = em.createQuery(sb.toString()).getResultList();
163+
} finally {
164+
context.setInternalIgnoreFilters(false);
165+
}
166+
157167
if (CollectionUtils.isNotEmpty(results) && results.get(0) != null) {
158168
Long maxEntityId = (Long) results.get(0);
159169
if (maxEntityId > maxSequenceId) {

0 commit comments

Comments
 (0)