quarkusio/quarkus · error · PanacheQueryException
Query string cannot be empty
Error message
Query string cannot be empty
What it means
PanacheJpaUtil.createUpdateQuery validates the query string passed to Panache update operations (`PanacheEntity.update(...)` / `PanacheRepository.update(...)`). A null query raises 'cannot be null' and a query that is empty or only whitespace raises 'Query string cannot be empty'. Panache requires a non-empty JPQL/HQL update statement because it delegates parsing (removing a leading 'update from' for backwards compatibility) to build the actual update query.
Source
Thrown at extensions/panache/panache-hibernate-common/runtime/src/main/java/io/quarkus/panache/hibernate/common/runtime/PanacheJpaUtil.java:117
}
if (trimmedForAnalysis.startsWith("order by ")) {
// ignore it
return "FROM " + getEntityName(entityClass);
}
if (trimmedForAnalysis.indexOf(' ') == -1 && trimmedForAnalysis.indexOf('=') == -1 && paramCount == 1) {
query += " = ?1";
}
return "FROM " + getEntityName(entityClass) + " WHERE " + query;
}
public static String createUpdateQuery(Class<?> entityClass, String query, int paramCount) {
if (query == null) {
throw new PanacheQueryException("Query string cannot be null");
}
String trimmedForAnalysis = trimForAnalysis(query);
if (trimmedForAnalysis.isEmpty()) {
throw new PanacheQueryException("Query string cannot be empty");
}
// backwards compat trying to be helpful, remove the from
if (trimmedForAnalysis.startsWith("update from")) {
// find the original from and skip it
int index = query.toLowerCase(Locale.ROOT).indexOf("from");
return "update " + query.substring(index + 4);
}
if (trimmedForAnalysis.startsWith("update ")) {
return query;
}
if (trimmedForAnalysis.startsWith("from ")) {
// find the original from and skip it
int index = query.toLowerCase(Locale.ROOT).indexOf("from");
return "UPDATE " + query.substring(index + 4);
}
if (trimmedForAnalysis.indexOf(' ') == -1 && trimmedForAnalysis.indexOf('=') == -1 && paramCount == 1) {
query += " = ?1";View on GitHub (pinned to e1c734241f)
Solutions
- Ensure the string passed to update(...) is a complete non-empty JPQL/HQL statement, e.g. "name = :name where id = :id"
- Trim/validate the query before calling update, and guard blank values from config/user input
- If the query is built dynamically, throw your own descriptive exception when the fragment list is empty instead of letting Panache fail
- Remember Panache allows omitting 'update Entity' / 'update from Entity'; pass only 'set ... [where ...]' content if using the shorthand, but never an empty string
Example fix
// before
String query = buildUpdateFragment(params); // may return ""
repo.update(query);
// after
String query = buildUpdateFragment(params);
if (query == null || query.isBlank()) {
throw new IllegalArgumentException("No update criteria provided");
}
repo.update(query); Defensive patterns
Strategy: validation
Validate before calling
if (query == null || query.trim().isEmpty()) {
throw new IllegalArgumentException("update query must be a non-empty JPQL fragment");
}
repository.update(query); Type guard
boolean isValidUpdateQuery(String q) {
return q != null && !q.trim().isEmpty();
} Try / catch
try {
repo.update(query);
} catch (PanacheQueryException e) {
log.error("Invalid update query supplied: '{}'", query, e);
throw new IllegalStateException("Check update statement construction", e);
} Prevention
- Validate dynamically built queries before passing them to update(...)
- Never pass raw config values straight into update without a blank check
- Unit-test query builders with edge cases (empty fragment lists)
- Remember Panache accepts 'set ... where ...' fragments — pass meaningful content, never ""
When it happens
Trigger: Calling PanacheEntityManager.update(...), PanacheEntity.update(...) or PanacheRepository.update(...) with an empty string, a string of only spaces/newlines, or a variable that resolved to an empty value (e.g. an empty config property or concatenated fragments that produced nothing).
Common situations: Dynamically building update statements from user input or configuration where the query fragment ends up empty; typo'd variable initialization; framework wrappers that pass through blank queries; migrating code where a condition made the query string empty.
Related errors
- The named query '${namedQuery}' must be defined on your JPA
- Query string cannot be null
- Sort column name cannot have backticks
- The annotation ProjectedFieldName must have a non-empty valu
- Entity '%s' was not found. Did you forget to annotate your P
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/88b89c8a9960dedf.
Report an issue: GitHub.