Skip to content

Diagnostics

Every failure the library raises carries a stable code of the form MQnnnn, the model's simple name where one applies, and the column or property involved. The meaning of a released code never changes, so you can search for it. Messages say what to change, for example OrderView.totl: no attribute 'totl' on OrderEntity.

Range When How it surfaces
MQ1xxx A query or write definition is invalid, found when build() or the first resolution runs ModelQueryDefinitionException
MQ2xxx Execution, paging, export and bulk writes ModelQueryExecutionException
MQ3xxx Your models, at compile time a compiler error from the annotation processor
MQ4xxx Configuration and vendor resolution, usually at startup ModelQueryConfigurationException

The three exceptions extend ModelQueryException, so one clause catches every failure the library raises, and its code() says which one it was. The one exception is the JPA OptimisticLockException an expectVersion update throws when it affects no rows (see Bulk writes).

try {
    return executor.page(query, PageSpec.of(0, 50), CountMode.NO_COUNT);
} catch (ModelQueryException e) {
    log.warn("query failed with {}", e.code(), e);
    throw e;
}
try {
    return orders.findPage(query, PageRequest.of(0, 50), CountMode.NO_COUNT);
} catch (ModelQueryException e) {
    log.warn("query failed with {}", e.code(), e);
    throw e;
}

MQ1xxx: query and write definitions

Code What went wrong
MQ1001 A column's declared type does not match the entity attribute; a value or map child field's declared element, key or value type is not the element collection's, at the plan build.
MQ1002 An attribute named by a column or join does not exist on its entity.
MQ1003 A column or table sits on a root entity the query is not rooted at.
MQ1004 A write reads a to-one by its id in its filter, set clause or an upsert's doUpdate(...).where(...), but the provider does not report the foreign key as a column of the entity's own table referencing the target's primary key. The message says "the provider reports that it is not" or "the provider cannot tell".
MQ1101 Two TableFields share a join key but carry different on(...) conditions.
MQ1102 on(...) used without as(...).
MQ1103 Two Agg.of fields share a name with different expressions.
MQ1104 as(...) or on(...) on a root TableField, which is not a join; presentBy(...) on a root that is not a joined entity (the query's root, a source root, a joined source's root, a treated root).
MQ1105 FieldIndex.only names a key the index doesn't hold, or leaves a kept set empty.
MQ1106 treat(...) misused: not a strict mapped subtype, a treat of a treat or of a source root, as(...) or on(...) on a treated join, or an ofType/notOfType type the entity hierarchy doesn't map.
MQ1107 A nested model's join is mapped wrongly, or not at all, to the outer join it stands for under a @Join: a JoinScope pair of another entity, source or kind, mapped twice or not registered within the field's own table, or a scoped row asked for a column on a joined root its scope does not map.
MQ1201 keyset() or primaryKeyFirst(...) without a primary key.
MQ1202 build() without select(...) or fetch(...).
MQ1203 Builder given a join instead of a root TableField.
MQ1204 PrimaryKeyFirst.whenOffsetAbove with a negative offset.
MQ1205 QueryCustomizer changed the ORDER BY or GROUP BY of a phase, or added distinct or having to a locked query.
MQ1206 A primary-key column of array type.
MQ1207 keyset() with a Float or Double order or primary-key column.
MQ1209 A lock on a grouped query, which has no row to lock.
MQ1301 A value-form filter received null.
MQ1302 A column or nested exists(...) path inside exists(...) is not on or below the given path.
MQ1303 A Filters or Having used after its operator returned, or while a nested operator runs.
MQ1304 exists(...) given a root instead of a join path.
MQ1305 A Filters.add predicate returned null.
MQ1306 One in or notIn filter has more values than maxBindParameters().
MQ1307 A statement binds more values than maxBindParameters() together; narrow its filters. A keyset page, export page or write round is refused before it runs when its own binds plus the worst cursor would pass the limit; the message says how many binds each side has.
MQ1308 A value cannot be converted to its column's attribute type, for example an Instant beyond the range of Timestamp; persist setting a primitive attribute to null.
MQ1313 A custom operator renderer or preparation returned null or threw; see below.
MQ1315 Invalid full-text configuration identifier at the factory call; see below.
MQ1401 Grouped query: selected non-aggregate column is not in the group-by.
MQ1402 Grouped query: keyset paging or primary-key-first not allowed.
MQ1403 Grouped query: Agg.sum or Agg.sumAsLong over a column whose SQL sum type differs from the result type.
MQ1404 Grouped query: aggregate passed to groupBy, which takes columns only.
MQ1405 Grouped query: Agg.of expression returned null, or Java type does not match declared type.
MQ1406 Grouped query: orderBy key does not fit the grouping (non-group-key column on grouped query, or aggregate on ungrouped one).
MQ1407 Grouped query: having(...) on an ungrouped query.
MQ1408 Grouped query: aggregate function over a column with a ColumnConverter (sum, sumAsLong, avg and avgExact, and round over a min or max of a converted column; min, max and countDistinct take an OrderedColumnField and do not compile over any other converted column).
MQ1409 Grouped query: column selected under a presentBy join whose key columns are not all group keys.
MQ1410 Runtime groupBy or group key over a column that selects a whole to-one entity. Group by the id form instead.
MQ1411 Agg.avgExact over a Double, Float or another input with no exact rendering, or Agg.round / Expr.round with a scale below 0 or above 30. Use Agg.avg for an approximate average, and a scale from 0 to 30.
MQ1412 filter(...) on a rounded aggregate (filter the aggregate it rounds), an Agg.of field or an already filtered aggregate, with a condition that leaves no filter, reads a correlated value, or is a filtered count(table) over an embedded or composite id with no usable first id attribute, or adds a to-many join; or an Agg.firstBy whose order key is an aggregate or window field, or whose value or order key is read through a to-many join.
MQ1502 An expression, operator, key, cursor or assignment value cannot bind, or binder failed; see below.
MQ1505 A CASE condition uses add, exists, a sub-select, a correlated value or op.
MQ1508 An Expr.constant cannot be rendered as a literal: its value is not a String, Number or Boolean after the column's converter, the column is not a basic attribute of a root table, the provider has no constant renderer, or it is used other than as a comparison or in operand. The message names the cause.
MQ1509 Expr.nextval misused: a name that is not a plain, optionally schema-qualified identifier, use in a filter, having, order or group key, or a vendor with no sequences (MySQL).
MQ1512 A query reads a QueryParam it doesn't bind, or two QueryParams share one name, at build; a bulk write, a fetch-plan child model reads one that neither it nor the child's key groups bind, or an engine-built statement reads one no binding covers; see below.
MQ1701 A fetch plan's join plan whose join has no column of the query's selection at or below it.
MQ1702 A column a fetch plan needs (a child's key, an enricher's column) is read through a to-many join; checked on first execution, and count logs a warning instead.
MQ1703 A fetch plan names the same child or join twice.
MQ1704 A fetch plan with a child, at any join depth, on a grouped query.
MQ1705 A join plan selects an aggregate, which cannot be re-rooted under the join.
MQ1708 A key-group definition that does not fit its child or query, at the plan build for a child and at build() for a query, before any statement: a key type unequal to the key's attribute type, a group param nothing reads or that the model also binds, verifyMissing with no bind or on a to-many child, or a group param read in a way the child or query does not allow. See Child loads over partitioned tables and Key groups.
MQ1713 A value, map or element child's statement joins a collection besides its element collection, which would repeat its values; an element child whose isElement() disagrees with its join, or a map child whose isElementModel() and elementQuery() disagree; at the plan build, before the parent's statement.
MQ1714 A map child's non-empty filter needs an @ElementModel value; the map has basic values. Refused when the fetch plan is built, before any statement.
MQ1601 Bulk write: no predicate left after skipping rows, or a conflict arbiter's where(...) whose filters were all skipped.
MQ1602 Bulk write: column is assigned twice.
MQ1603 Bulk write: set(column, null) called; NULL must be written with setNull.
MQ1604 Bulk write: assigned column is not on the root (self-referencing join).
MQ1605 Bulk write: primary-key or @Version column is assigned.
MQ1606 Bulk write: expectVersion used incorrectly or on a root with wrong type.
MQ1607 Bulk write: Changes.from(...) names a column that is not writable.
MQ1608 Bulk write: @PrimaryKey is not the root entity's id.
MQ1609 Bulk write: setExpression on a column with a converter.
MQ1610 Bulk write: an update throughEntities() combined with keepVersion(), expectVersion(v) or setExpression, whatever the call order.
MQ1611 Write assignment: an unknown path, an id, a @Version, a collection, a to-one or a whole embeddable, overlapping kinds for one path, or an entity class that is a subclass of the write's root.
MQ1612 Write assignment: a type the attribute cannot take, or a supplier returning null or the wrong type.
MQ1613 Write assignment: a setExpression(column, ExpressionField) whose expression reads a column or binds a parameter, or an insert-values with one on a provider that cannot render it.
MQ1801 Insert: a column is not mapped, is mapped or set twice, is not on the written root, or is not in the model's InsertColumns; a map between columns with different converters or types; lockKeys() on insert-values; insertReturningKeys with commitEachChunk().
MQ1802 Insert: the model names a generated id, lacks an id that has no generator, a setExpression writes the id, or a row has a null assigned id; persist names a generated id (where the provider reports the generator) or part of a composite id.
MQ1803 Insert: a null row.
MQ1804 Invalid insert conflict clause or unsupported conflict filter; see below.
MQ1805 Insert: a generator that is not supported for the call (a pooled sequence or a table or UUID generator on an insert-select), a JOINED or @SecondaryTable root, a composite id with generated parts, @MapsId, or a constructor-only embeddable under persist.
MQ1806 Insert: a chunked insert-select whose source and target overlap, or whose tables the provider cannot name, or whose source joins through a link or collection table (@ManyToMany, @ElementCollection, a @OneToMany over a join table).
MQ1807 Insert: keys requested for an IDENTITY or assigned id, or a key type that is not the id's type.
MQ1808 Insert: two rows of one insert-values call with a conflict clause share a conflict-key tuple.
MQ1809 persist(persist, returning): a query with a where or having that recorded a filter, groupBy, a fetch plan, customize, orderBy, keyset or primaryKeyFirst, a lock, a joinSource(...), or a column the flushed entity cannot fill. A returning write also refuses a column on a table other than the written one, throughEntities() and commitEachChunk().
MQ1901 keyset() or primaryKeyFirst(...) on a query over a non-unique source, whose key does not identify a row.
MQ1902 A recursive source built wrongly: a maxDepth below 1 or above Integer.MAX_VALUE - 2, recursive(...) on a model with no @Depth, a @Depth model built without recursive(...), or a depth(...) column that is not among the fields.
MQ1903 A row lock on a query that reads or joins a source: a locking clause cannot follow through a common table expression.
MQ1904 Two branches of one set operation fix the same @Discriminator value, two combined sources read different shapes or fields in a different order, type or converter, a discriminator column is not a key column, or a side of the operation is a recursive source.
MQ1905 A hand-written ColumnField.of or TableField.join over a source root, or joinSource on a query rooted at a source; a generated outer column is ColumnField.over(model, root, sourceConstant).
MQ1906 A source's where predicate whose path crosses a to-many join, which no join inside the CTE can express; use Filters.exists(path, inner).
MQ1910 A joinSource binding refused when the query is built, before any statement: its SourceJoin pairs miss a key field of the source, name a field that is not a key field or pair one twice; the source is not unique (a set operation, a plain recursive(...) source or an ungrouped source over one; the message names tree(...) when it recurses); one join is bound twice, by name; a source of another model is bound through a raw type; the joined chains walk more than one recursive source; a hand-written on(...) pair has a converted source key field or differing attribute types; or an outer column reads an entity join the query does not bind, one anchored on a joined source, another joined source's columns, or, for an INNER source, a LEFT entity join; at first resolution, an outer column read through a to-many path, which would repeat an outer row. See Joining a source.
MQ1911 Invalid hand-written entity join; see the checks below.
MQ1912 Invalid request-bound join filter; see the checks below.

MQ1512 also covers one name shared by two different params, even when both are bound. A bulk update, delete or insert whose where or conflict update's where reads a param is MQ1512 at its build, a conflict arbiter's is MQ1804, setExpression with an expression reading one is MQ1613, and a fetch plan whose child model reads one is MQ1512 when the plan is built. A bound param that nothing reads is allowed, and inspection names params by name and type, never by value.

MQ1911 rejects a converted anchor, pairs over two joined sources or an unbound source, pairs mixing a joined source's columns with the root's, a refused chain (a column anchor over an entity join bound after it, its own root, one the query does not bind or one anchored on a joined source, or an INNER join anchored on a LEFT one), a treated node, a source or an Outer lift, a query rooted at a source, a duplicate name, or a bad when term (a second one, a converted column, one a chain could not read, or on a source-anchored join one off the root and its to-one paths, or a value that is null, not of the column's boxed type or not bindable) at build. At first resolution before SQL it rejects partial, extra, repeated, non-id or association-id pairs, boxed-type mismatches, to-many paths, and a column anchor through a to-many path or reading a to-one by its id; an entity class the render options' metamodel rejects as unmapped (without a metamodel, the provider decides: Hibernate may throw its own exception). A column over an entity join the query does not bind is MQ1003. See Entity joins.

MQ1912 rejects a root or INNER join, a filter on an entity join the query does not bind, another table or descendant path, exists, an aggregate, window or correlated value, or a sub-query crossing the join at build. At first resolution before SQL it rejects id-form access, a join key whose filter is never applied, another key resolving to the same join, or filter columns creating a descendant join. It also rejects a join that renders INNER (declared, and not turned LEFT) below a filtered join, an INNER entity join whose column anchor or when column reads through a filtered join, and an INNER joined source whose outer column reads through a filtered join, at the first statement that resolves it; declare it LEFT.

For MQ1313, the message names the operator and column; a thrown RuntimeException is the cause. Preparation fails when adding the filter, rendering when building the statement. A ModelQueryException keeps its own code. MQ1315 requires ASCII letters, digits and underscores, starting with a letter or underscore, with at most one schema qualifier (english, public.my_config). Null, blank, quoted, $ and non-ASCII names are refused (AC-FLT-32).

For MQ1502, expression values exclude null, Optional, arrays, Collection, Map, Date, Calendar, enums and entities. Operator values always exclude Optional, Collection and Map. Without a mapping-aware binder, only strings, java.lang or java.math numbers and java.time values bind: a value of a mapping-dependent type (an enum, Boolean, UUID, array, or a converter's non-JDK attribute type) fails with MQ1502. That restriction also applies to a <C, V> operator and an expression the binder declines through typesBy, even with a binder installed. Under inline value handling (hibernate.criteria.value_handling_mode=inline, ProviderSupport#inlinesValues), every filter value, call-time key (one(q, key), byKeys, primary-key-first pages), keyset cursor, fetch-plan round key, and update assignment binds as an explicit statement parameter: where no binder types the column, a value of a mapping-dependent type (an enum, Boolean, UUID, array, or a converter's non-JDK attribute type) fails with MQ1502 naming the operation and column before any statement runs (R-FLT-08). For call-time inputs, MQ1502 indicates input the environment cannot bind rather than an invalid query definition (D-177). A binder throwing, returning null or reusing a parameter already bound by the statement also fails with MQ1502, naming the operator and column, before any statement runs (R-FLT-21, R-VND-24).

For MQ1804, conflict columns must be the id, a natural id or a declared unique constraint. Other causes include doNothing the provider cannot render; a vendor detecting any unique key without anyUniqueKey(); a doUpdate assigning a key column or reading two or more assigned columns in its where without conflictUpdateWhereOnAssignedColumns(true); a blank onConstraint name; or an onConstraint or arbiter where the vendor does not support. Any op in an arbiter's where fails at build(); a value-form op in a conflict update's where fails on first execution, naming the operator. Field-form op is allowed there (R-WRT-34, R-WRT-52).

See Running queries, Filters, Grouped queries, Bulk writes and Inserts.

MQ2xxx: execution

Code What went wrong
MQ2001, MQ2002 A page, export or chunk size is not positive, a limit is negative, or an offset is negative.
MQ2005 byKeys read a row whose key equals none of the requested values: the column's collation is case-insensitive or ignores trailing spaces, or a BigDecimal key's scale differs.
MQ2101 Streaming needs a transaction on this database (PostgreSQL).
MQ2102 A locked read ran without an active transaction.
MQ2201 A row's primary key mapped to null during export or primary-key-first paging.
MQ2202 A keyset column is NULL and has no explicit nullsFirst()/nullsLast().
MQ2203 An operation that needs a primary key was used on a query without one.
MQ2204 Key-based paging or offset export over a selection read through a to-many join.
MQ2205 A keyset export page repeated a key of the page before; or a chunked write's key select returned a key it already wrote.
MQ2206 A QueryCustomizer narrows the phases of a primary-key-first query differently.
MQ2211 A lock on a read that refuses one: page, count, stream and export refuse any lock, one(q) refuses SKIP_LOCKED, and a locked query whose statement has a join, such as a to-one id read, is refused. Filter the related rows with Filters.exists(...) instead of joining.
MQ2212 A read that identifies a row by its key on a query over a non-unique source: export, byKeys, one(q, key), a fetch plan with a child, a join plan or an enricher, or an offset page whose selected column cannot be ordered.
MQ2215 A query with key groups read by anything but byKeys or one(q, key): list, page, count, one(q), first(q), export, stream, or as the returning query of a write; before any statement, naming the call and the params the groups bind. See Key groups.
MQ2301 A sort property resolves to no column or to several, asks for ignoreCase, or names a sort on a query without a primary key.
MQ2501 A bulk write ran without an active transaction.
MQ2502 A chunk of a chunked write failed; ChunkedWriteException says what was committed.
MQ2503 An entity-mode update loaded a proxy your persistence context held for a row, and no ProviderSupport can unwrap it; add model-query-hibernate for Hibernate, or write under CLEAR. Nothing in the chunk was changed.
MQ2601 A to-one @Child found two distinct rows for one key.
MQ2602 An Enricher.of returned null, or a page of another size than it was given.
MQ2603 A parent has more children than maxPerParent, or one statement of a child load read its row cap.
MQ2604 A child row's key equals none of the keys it was matched to: the column's collation is case-insensitive or ignores trailing spaces.
MQ2605 stream with a fetch plan that loads children, join plans or enrichers; use export.
MQ2607 A key-group function returned null; the message names the key. After the parent's statement and before the child's first round; for byKeys and one(q, key), before any statement.
MQ2608 A key's row was found only by the verifyMissing re-read of a child load, byKeys or one(q, key); logged at WARNING once per definition, naming it and a sample key, never a bound value, never thrown.
MQ2609 Two entries with the same Java key for one parent in a map child, which a lossy key converter can cause; names the field, the parent key and the map key.
MQ2701 A recursive source's tree is deeper than its maxDepth. The message names the model, the limit and the key of the first row past it.
MQ2702 A recursive source's graph closed a cycle. The message names the model and the first key the cycle clause marked.
MQ2703 A tree reached a key twice; narrow the seeds or use recursive(...). The message names the model and the first column of the smallest duplicated key.

See Paging and export and Bulk writes.

MQ3xxx: your models, at compile time

The processor reports these as compiler errors (a few as warnings) pointing at the field.

Code What went wrong
MQ3001 Unknown attribute, or a dotted @Column(attribute) that leaves embedded values.
MQ3002 Model type is not the entity attribute's type, and no converter provided or built in (Instant or Date over a Timestamp). On a to-one, a column that is not the target's id type, or whose mapping cannot be read by id (the message names the reason). An @ElementCollection element or map key type that cannot be read (D-260).
MQ3003 @Join attribute is not a to-one association, or the nested model's root does not match the target.
MQ3004 Missing @PrimaryKey on a model with no @Aggregate field.
MQ3005 @Join field is not Optional<X>, or X is neither a @QueryModel nor bound by a @BindQueryModel, or X has an @Aggregate or @Computed field.
MQ3006 Nested model has no @PrimaryKey, so presence cannot be decided.
MQ3007 Join cycle between nested models.
MQ3008 Class model has no no-arg constructor visible from its package.
MQ3009 Record component is primitive and not @PrimaryKey.
MQ3010 Record has only a non-canonical constructor, or is generic.
MQ3011 @FilterColumn path does not resolve, crosses a collection with no explicit joinType, ends at an element collection's embeddable elements, or reaches an association inside them.
MQ3012 Two @FilterColumns with the same alias and path prefix but different joinType.
MQ3013 @FilterColumn name clashes with a generated constant, is reserved, or is not a legal Java name.
MQ3014 converter is not a ColumnConverter between the field type and the attribute type.
MQ3015 Two generated constants would have the same name, or a constant clashes with a reserved one.
MQ3016 A warning, not an error: a column on a to-one association selects the whole entity and has no converter. The message shows the @Column(attribute = …) id form that reads only the foreign key.
MQ3017 The model's root, or the root of a model it nests, is not a class, and no annotation processor generated it. A root another processor generates is fine: the model waits for it. Also reported on a @BindQueryModel binding whose root, or a nested model's root, is never generated.
MQ3018 A @Computed or @Aggregate(expression) class is not a usable ExpressionDefinition<Model, FieldType>: its type arguments are not the model and the field's boxed type, or it has neither a public INSTANCE nor a visible no-arg constructor.
MQ3019 @Computed combined with @PrimaryKey, @Column, @Join, @Child, @Aggregate or @Transient, or on a primitive field.
MQ3020 @Selected field that is not exactly SelectSet<Model>, or a second @Selected field in the model.
MQ3021 @Selected combined with another field annotation of the library.
MQ3022 Warning: a @FilterColumn whose key in fields() a mapped column, a @Computed field or another @FilterColumn already holds is left out of fields() and stays a constant.
MQ3023 A model bound twice for one kind (in any round or package), or bound and annotated; or two bindings, or a binding and an annotated model, that would generate one class name. Keep one, or give one a prefix or another package.
MQ3024 A bound model, or a type enclosing it, that is not public, or a constructor, setter or getter the generated classes call from the binding's package that is not public; or a model that is no class or record.
MQ3025 A @Computed with no value and no @BindExpression, or on an annotated model; or a @BindExpression naming an unknown field, a field that is neither computed nor aggregate, one that already names a definition, or a field twice.
MQ3026 A @Join or @Child model of a bound model that is neither annotated nor bound in the same compilation. Bind it as well.
MQ3027 The modelquery.jspecify option is set but JSpecify is not on the classpath. Add org.jspecify:jspecify to the module that compiles the models.
MQ3028 @GroupBy on a column that selects a whole to-one entity. Group by the id form instead: @Column(attribute = "customer") Long customerId.
MQ3029 The id form of a to-one whose target has @SQLRestriction or @Where: a read would take a null id from a restricted row while the foreign key holds a value. Read it through a @Join.
MQ3030 @Child on a @SourceModel: a source is one statement, so it has no parent query to fill a child from.
MQ3031 A source model's @PrimaryKey is neither the root entity's id nor the full @GroupBy set, a group key is nullable in its mapping, or a @FilterColumn path crosses a to-many join. Filter it with Filters.exists(...) instead.
MQ3032 @Window is not well written: a term naming no attribute, an argument written where the function takes none, a field of another type, an order-sensitive function without orderBy, a missing or misplaced frame, a frame on a ranking function, or a grouped source's term that is neither a group key nor an aggregate.
MQ3033 @Window on a model that is not a @SourceModel.
MQ3034 A branch does not map its shape: a field of another name, type or mapping, a missing or extra field, a @PrimaryKey that is not the shape's, or a @Discriminator that is missing, doubled or misplaced.
MQ3035 @Join on a model rooted at a source, which has no associations: an outer model reads its source's columns by field name.
MQ3036 An outer model's @PrimaryKey is not exactly its source's key.
MQ3037 A recursive source is not well written: a @Depth that is not one Integer, a second one, a @Depth outside a @SourceModel, or @Window, @Aggregate or @GroupBy beside it.
MQ3038 A model's root is neither an @Entity nor a @SourceModel, or both.
MQ3039 @Child whose child model is rooted at a source, joins one (@JoinSource), or declares an entity join, directly or through a nested @Join: a fetch plan has no source or join to pass it.
MQ3040 generateChanges on a model rooted at a source. A write needs an entity root; read the source through an outer model instead (Source models).
MQ3044 @JoinSource or @SourceColumn written wrongly: on misses or exceeds the source's key, pairs a key twice or mismatches a type, an unknown root attribute, source field or join, a class that is no @SourceModel, a repeated join name, a key field with a converter, a @SourceColumn beside @PrimaryKey or an annotation that makes the field no column, a model that is not a @QueryModel rooted at an entity, or a nested @Join model's own joins that sit below a @Join(entityJoin) naming a join anchored on a joined source, are INNER below a LEFT @Join, anchored on a @FilterColumn, read an entity join through an association or treat, or clash with a declared join's constant or name.
MQ3045 @Aggregate with orderBy but not FIRST_BY (or FIRST_BY without one), an unknown or malformed orderBy key, a filter class that is no public FilterDefinition of the model with an INSTANCE or no-arg constructor, a scale outside 0 to 30 or on a field that is not a BigDecimal, or an AVG field typed BigDecimal over a Double or Float attribute.
MQ3046 Invalid @JoinEntity, joined-entity column or joined-entity aggregate; see the checks below.
MQ3047 Invalid @Join(entityJoin): named join not found, entity mismatch with nested root, type, attribute or treat written with entityJoin, or an INNER join below a LEFT entity join (Source models).
MQ3201 Aggregate model: field is primitive.
MQ3202 Aggregate model: field type does not match the function's result type.
MQ3203 Aggregate model: no @GroupBy field and is not singleGroup.
MQ3204 Aggregate model: @GroupBy combined with @Aggregate or @Join.
MQ3205 Aggregate model: @Aggregate(fn = SUM) over a 32-bit attribute.
MQ3206 Aggregate model: @Aggregate(distinct = true) on SUM, AVG, MIN or MAX.
MQ3207 Aggregate model: @QueryModel(singleGroup = true) combined with @GroupBy fields.
MQ3208 Aggregate model: @Aggregate takes attribute or expression, not both.
MQ3301 Update model: field maps through a join or a collection.
MQ3302 Update model: @Join, @Aggregate, @GroupBy, @Computed or @Selected not allowed.
MQ3303 Update model: field maps to the primary key or @Version attribute.
MQ3304 Update model: field maps to an attribute that can't be written.
MQ3305 Update model: to-one attribute written by id with the wrong id type.
MQ3306 Update model: @PrimaryKey is not the root entity's id.
MQ3307 Update model: field generates a change-set member that clashes with Changes<M>.
MQ3401 @Child field is not a List or Optional of a @QueryModel or bound model, carries @Join, @Transient, @Aggregate or @GroupBy, is on an update model, or sets both through and foreignKey.
MQ3402 @Child key or foreignKey names no attribute of its root, names an association rather than one of its attributes, or crosses a collection in key. A foreignKey may cross one, for a many-to-many child.
MQ3403 @Child key and foreignKey attributes have different types.
MQ3404 @Child key of several attributes, an embedded value or an array: it takes one attribute each side.
MQ3405 A List @Child without foreignKey (unless it has through), or whose model has no @PrimaryKey; or an Optional @Child whose through crosses a collection, on a model with no @PrimaryKey.
MQ3406 @Child(through) whose path is blank, crosses something other than an association, or ends at another type than the child model's root; whose key is not the parent root's single @Id; whose child model is grouped; or whose parent is rooted at a source, which has no entity to join along. Use foreignKey.
MQ3407 A value child that is not a List or Set of the element type (an Optional or a Collection included), a Map field over a collection that is not a map or the other way round, or a field over embeddable elements that is not a List of their @ElementModel.
MQ3408 @Child on a Map element collection whose key is an entity or an embeddable, or on a Map<K, Entity> association; read the association as @Child(through = "...") List<...>.
MQ3501 Insert model: names a generated id, or does not name all of an id that has no generator with @PrimaryKey. On a generateInserts query model, an assigned id that no written column covers, including one an @ExcludeFromInserts field is.
MQ3502 Insert model: @Join, @FilterColumn, @Aggregate, @GroupBy, @Computed, @Child, @Selected or @Transient field.
MQ3503 A type carries more than one of @QueryModel, @UpdateModel and @InsertModel. To read and create one row shape with one model, use @QueryModel(generateInserts = true).
MQ3504 Warning: the insert model's root shows the processor no id type, so the generated insert and persist type their keys as Object.
MQ3506 @ExcludeFromInserts on a model without generateInserts, on an update or insert model, or on a field generateInserts already leaves out.

MQ3046 rejects an invalid entity or name, constant collision, partial, extra, repeated, non-id or association-id pairs, converted anchor, boxed-type mismatch, unknown source field, a source that names no @JoinSource of this model, duplicate join name, unknown @Column.entityJoin, @FilterColumn.entityJoin or @Aggregate.entityJoin, both or neither of field and column on one pair, pairs mixing the two, a column with a source or a field without one, an anchor over a joined source, a refused chain (an anchor over an entity join declared after it, itself, one anchored on a source, or an INNER join anchored on a LEFT one), a to-many or treated path, an expression or a to-one read by its id, a when column that is converted or enum-typed, a value that does not bind or parse as its boxed type, or a second when, to-many path below the entity, nested @Join, joined-column @PrimaryKey, declaration on @SourceModel, treat combined with entityJoin, or a nonempty @Aggregate.entityJoin combined with expression (including @BindExpression), for any function.

See Models and QModels.

MQ4xxx: configuration

Code What went wrong
MQ4001 modelquery.vendor or modelquery.target-vendors names an unknown vendor.
MQ4002 Two vendor profiles are registered for the same vendor with no precedence rule.
MQ4003 A property value, or its ModelQueryConfig setting, is out of range.
MQ4004 commitEachChunk() with no ChunkTransactions that serves the write's EntityManagerFactory.
MQ4005 modelquery.vendor set with more than one EntityManagerFactory and no ModelQueryConfigurer.
MQ4006 A ModelQueryConfig bean of your own drops a VendorProfile, WriteAssignment or ChunkTransactions bean, or a set modelquery.* property.
MQ4007 A repository declares ModelQueryRepository of an entity other than its domain type.
MQ4009 A bulk insert on a factory whose persistence provider has no insert support, before any statement. persist still runs.
MQ4010 A locked read whose provider cannot render the lock: no lock support, a strength or wait it does not render, or a root entity mapped to more than one table.
MQ4011 A returning write the factory cannot return rows for, such as any returning write on MySQL.
MQ4012 A factory is not on one of the declared target vendors; the message names the factory, its vendor, how it was found and the list.
MQ4013 The portability check cannot boot your unit offline for a target: no provider support for its vendor, a vendor with no offline boot (Oracle, SQL Server, OTHER), or a version that is not numeric.
MQ4014 Missing provider renderer, source check or custom operator feature support; see below.
MQ4015 The vendor lacks a source, operator or aggregate feature, an entity join anchored on a joined source lacks CTE, or a recursive source exceeds its depth limit.

For MQ4014, ProviderSupport#sources() is empty, there is no ProviderSupport, or the provider's SourceRenderer returned no duplicate-key check for tree(...). An operator requiring a feature also needs an operator gate and a provider that serves that feature (ProviderSupport#operators), after the vendor check passes. A query that joins a source whose SourceRenderer has no join hook, an Agg.avgExact with no AggregateRenderer#exactAverage, and an Agg.firstBy with no AggregateRenderer#firstBy (or no native FILTER form when filtered) are also MQ4014, as is an entity-join renderer that does not call on exactly once, returns another join than the one it passed to on or returns one with no ON (the message names the renderer class). All are refused before any statement; the portability check reports them per declared target with no database attached.

For MQ4015, VendorProfile#operators refuses an operator's required feature before the provider check (MQ4014), and VendorProfile#aggregates does the same for an Agg.firstBy: false on MySQL and OTHER. A joined source needs the same source features as a source root, so it is MQ4015 where CTE is false (OTHER). An entity join anchored on a joined source needs CTE too; one anchored on the root's columns needs no vendor fact and renders on OTHER. The message names the feature, vendor, operator and column. For sources it names the unsupported feature or depth: maxDepth + 2 must fit VendorProfile#maxRecursionDepth() (R-VND-23).

See Spring Data and the starter and Vendor notes.

Logging

model-query logs through System.Logger, which reaches SLF4J, Logback or Log4j through their System.Logger bridges, and java.util.logging without one (where DEBUG is FINE and TRACE is FINER).

Logger Level What it logs
com.rey.modelquery.core.ModelQuery DEBUG Each query definition build() returns: model, entity, selected fields, primary key, filters (kind and column, each value shown as ?), group-by, order and paging mode.
com.rey.modelquery.jpa.DefaultModelQueryExecutor DEBUG Each list, stream, page, count, export, update and delete call, with its limit, page or export options; a write also lists how it chose its rows (the number of keys or all rows) and its filters, each value shown as ?, and how it runs.
com.rey.modelquery.jpa.DefaultModelQueryExecutor TRACE Each statement's bind count against the vendor's limit, then its rows read or written and the time it took.
com.rey.modelquery.jpa.DefaultModelQueryExecutor WARNING MQ2214: an offset page over a treated statement that returns more rows than total - offset, logged once per ModelQuery (never thrown).
DEBUG com.rey.modelquery.core.ModelQuery - built OrderView over OrderEntity: select [id, status, total], primaryKey [id], where [EQ(OrderView.status, ?), GT(OrderView.total, ?)], orderBy [total DESC NULLS LAST], paging keyset
DEBUG com.rey.modelquery.jpa.DefaultModelQueryExecutor - page OrderView: offset 100 size 50, NO_COUNT
DEBUG com.rey.modelquery.jpa.DefaultModelQueryExecutor - update OrderEntity (where [EQ(OrderView.status, ?)]): direct
TRACE com.rey.modelquery.jpa.DefaultModelQueryExecutor - OrderView: statement binds 3 of 65535
TRACE com.rey.modelquery.jpa.DefaultModelQueryExecutor - OrderView: 51 rows in 12 ms

Filter values (the build log shows each as ?), bind values and keyset cursors are never logged, since they often hold personal data, and neither is the statement text. Turn on your provider's SQL and bind logging for those, for example Hibernate's org.hibernate.SQL and org.hibernate.orm.jdbc.bind. With Spring Boot:

logging.level.com.rey.modelquery=DEBUG
logging.level.com.rey.modelquery.jpa.DefaultModelQueryExecutor=TRACE

This works with spring-boot-starter-logging, Spring Boot's default: its jul-to-slf4j bridge carries the records to Logback, and Spring Boot keeps the java.util.logging levels in step with Logback's, at startup and on every later change, such as a Spring Cloud refresh or the loggers endpoint. Through that bridge, a TRACE line prints as DEBUG.

If you exclude spring-boot-starter-logging and add Logback yourself, nothing carries the records to it, and anything below INFO is dropped. Add org.slf4j:slf4j-jdk-platform-logging, which Spring Boot manages: it sends System.Logger straight to SLF4J, keeps TRACE as TRACE, and follows level changes, since SLF4J reads them from Logback each time.

MockServer and java.util.logging reset

MockServer 5.x resets the java.util.logging (JUL) configuration on startup, which detaches handlers and resets log levels. Set the java.util.logging.config.file system property before MockServer starts, or route System.Logger directly through SLF4J with org.slf4j:slf4j-jdk-platform-logging.

Reporting a problem

If you meet a failure without a code, that is a bug: please report it with the stack trace and the model involved.