Skip to content

Commit 3f22885

Browse files
committed
fix: correct JPQL field name subThemeDiscriminatorValue → subTheme in JPADAO queries
The field was renamed in CMSPage entity in commit 02debd5 (refs #27710), but three JPQL queries in JPADAO and the corresponding test assertions were not updated, causing an IllegalArgumentException at runtime. refs #27710
1 parent b022ac9 commit 3f22885

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

goobi-viewer-core/src/main/java/io/goobi/viewer/dao/impl/JPADAO.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,7 +4534,8 @@ public List<CMSPage> getCMSPagesForSubtheme(String subtheme) throws DAOException
45344534
preQuery();
45354535
EntityManager em = getEntityManager();
45364536
try {
4537-
Query q = em.createQuery("SELECT DISTINCT page FROM CMSPage page WHERE page.subThemeDiscriminatorValue = :subtheme");
4537+
// Use field name 'subTheme' as defined in CMSPage entity (was previously named subThemeDiscriminatorValue)
4538+
Query q = em.createQuery("SELECT DISTINCT page FROM CMSPage page WHERE page.subTheme = :subtheme");
45384539
q.setParameter("subtheme", subtheme);
45394540
return q.getResultList();
45404541
} finally {
@@ -4615,7 +4616,7 @@ public static String createCMSPageFilter(Map<String, Object> params, String page
46154616
.append(templateParameter)
46164617
.append(" = ")
46174618
.append(pageParameter)
4618-
.append(".subThemeDiscriminatorValue")
4619+
.append(".subTheme")
46194620
.append(" OR ");
46204621
params.put(templateParameter, subtheme);
46214622
}
@@ -4625,7 +4626,7 @@ public static String createCMSPageFilter(Map<String, Object> params, String page
46254626
}
46264627
query += ") AND";
46274628
} else if (allowedSubthemes != null) {
4628-
query += " (" + pageParameter + ".subThemeDiscriminatorValue = \"\") AND";
4629+
query += " (" + pageParameter + ".subTheme = \"\") AND";
46294630
}
46304631

46314632
index = 0;

goobi-viewer-core/src/test/java/io/goobi/viewer/dao/impl/JPADAOTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,7 @@ void testCreateCMSPageFilter_createValidQueryWithAllParams() throws AccessDenied
21382138

21392139
String query = JPADAO.createCMSPageFilter(params, "p", templates, subThemes, categories);
21402140

2141-
String shouldQuery = "(:tpl1 = p.templateId OR :tpl2 = p.templateId) AND (:thm1 = p.subThemeDiscriminatorValue) AND "
2141+
String shouldQuery = "(:tpl1 = p.templateId OR :tpl2 = p.templateId) AND (:thm1 = p.subTheme) AND "
21422142
+ "(:cat1 IN (SELECT c.id FROM p.categories c) OR :cat2 IN (SELECT c.id FROM p.categories c) OR :cat3 IN (SELECT c.id FROM p.categories c))";
21432143
assertEquals(shouldQuery, query);
21442144

@@ -2161,7 +2161,7 @@ void testCreateCMSPageFilter_createValidQueryWithTwoParams() throws AccessDenied
21612161

21622162
String query = JPADAO.createCMSPageFilter(params, "p", null, subThemes, categories);
21632163

2164-
String shouldQuery = "(:thm1 = p.subThemeDiscriminatorValue) AND "
2164+
String shouldQuery = "(:thm1 = p.subTheme) AND "
21652165
+ "(:cat1 IN (SELECT c.id FROM p.categories c) OR :cat2 IN (SELECT c.id FROM p.categories c) OR :cat3 IN (SELECT c.id FROM p.categories c))";
21662166
assertEquals(shouldQuery, query);
21672167

0 commit comments

Comments
 (0)