BoxLang 🚀 A New JVM Dynamic Language Learn More...
|:------------------------------------------------------: |
| ⚡︎ B o x L a n g ⚡︎
| Dynamic : Modular : Productive
|:------------------------------------------------------: |
Copyright Since 2023 by Ortus Solutions, Corp
www.boxlang.io | www.ortussolutions.com
bx-orm announces onORMQuery, onORMFlush and
onORMException events for SQL and flush activity, and
exposes Hibernate statistics through
ORMService.getStatistics(). See ORM Observability Events.
box install bx-orm
# or, outside CommandBox
install-bx-module bx-orm
bx-orm 2.0 (Hibernate 7.4, BoxLang 1.18.0+) is in pre-release for
testing. Ask for a pre-release by version, for example box
install [email protected]; the releases
page lists them.
next;
send pull requests there. development carries 1.x until
2.0.0 is final../gradlew installModuleDependencies downloads the
BoxLang runtime jar and the bx-mysql module the tests use.docker-compose up -d mysql starts the MySQL instance
the test suite uses. Derby and SQLite tests are embedded../gradlew build (or ./gradlew test --tests
'<pattern>'). Run ./gradlew spotlessApply
before committing.2.0.0-<label>.N from next with
Actions > Pre-Release (next)..agents/skills-custom/.This project includes AI agent skills in .agents/skills/
to assist with development. To install them for use by your agents:
npx skills experimental_install
BoxLang is a professional open-source project and it is completely funded by the community and Ortus Solutions, Corp. Ortus Patreons get many benefits like a cfcasts account, a FORGEBOX Pro account and so much more. If you are interested in becoming a sponsor, please visit our patronage page: https://patreon.com/ortussolutions
"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
entityFacades setting; the generated POJO facade is now the only representation. No application change needed.hbm.xml writer (HibernateXMLWriter) and the ormXmlMapping setting; the module always emits the modern Hibernate 7 mapping.xml.Deleting an entity with entityDelete() (also entity.delete() and cborm) no longer fails at flush with orm.transient when children that point at it through a many-to-one are still loaded in the session. This restores the bx-orm 1.x behavior for apps whose database cascades the delete: entityDelete() evicts the loaded children that already exist in the database and reference the deleted entity, so the flush succeeds and the database removes their rows. If the database does not cascade, its own foreign key constraint still fails the delete. Pending changes on an evicted child are discarded. Declare onDelete="cascade" on the association to make the cascade explicit and have it in the generated schema.
The orm.transient error says when the referenced entity was deleted in the same session (ContentBlockVersion.contentBlock points to a ContentBlock that was deleted in this session.) instead of claiming it was never saved, names both entities, and tells you to delete the children first or declare onDelete="cascade". A reference to an entity that really was never saved keeps the "never saved" message. The error type is unchanged.
Boot cache manifests record entity sources as BoxLang paths under their entity root (for example /models/Task.cfc) instead of absolute machine paths, so a cache built on a CI runner, in a Docker build stage or in another folder still detects changed entities where it is deployed. The manifest format is now 2: regenerate existing caches (module:orm generate or one auto boot); a trust boot refuses a format 1 manifest.
A plain array param value in ormExecuteQuery() (and cborm executeQuery()) is a list param, as in bx-orm 1: id in (:ids) with { ids : [ 1, 2 ] }, and approver = :employee with [ employee ], work without list : true.
unique=true on ormExecuteQuery() and entityLoad() (filter form) is strict: more than one matching row raises orm.query.nonUnique instead of silently returning the first. Pass { uniqueFirst : true } for the old behavior. unique given inside the options struct is now honored.
ORM errors are orm.* exceptions instead of raw Hibernate/JPA exceptions. Code catching Hibernate class names should catch "orm" instead.
Unused named HQL parameters are logged as a warning.
eventHandling is honored: ORM events (entity methods, the global eventHandler, postNew) only fire when eventHandling=true. Before, they always fired. Apps that use events without setting eventHandling: true must add it.
entityLoadByPK()'s third argument is an options struct (lock, timeout, skipLocked, readOnly). A boolean third argument (Lucee's unique) is accepted and ignored.
Criteria asStruct() returns date values as ISO 8601 strings, like entityToStruct() and entityLoadAsStruct().
useDBForMapping now works (it was ignored before). It stays off by default.
Upgraded the ORM engine from Hibernate 5.6.15 to 7.4.8. BoxLang-facing BIF behavior is preserved.
Build and test against BoxLang 1.18.0 (was 1.11.0); the module's minimum BoxLang version is now 1.18.0 due to several updates we required in the new approach.
Legacy dialect aliases (e.g. MySQL57, Oracle10g, DerbyTenSeven) and removed Hibernate 5 dialect classes (e.g. org.hibernate.dialect.MySQL5InnoDBDialect) now map to their Hibernate 7 equivalents with a one-time deprecation warning; community-dialect databases (SQLite, Derby, Firebird, …) resolve automatically.
ormGetSession() / ormGetSessionFactory() return facade-aware wrappers so a BoxLang entity name or instance works against the raw Hibernate API. Calls on an entity the session does not hold still throw Hibernate 5's org.hibernate.TransientObjectException (Hibernate 7 throws IllegalArgumentException), so code such as ColdBox's object populator keeps detecting new entities.
ORM operations inside a BoxLang transaction{} now ride the transaction's JDBC connection instead of the ORM running its own separate Hibernate transaction. BoxLang owns the real commit/rollback, so ORM writes are governed by the same demarcation as native queryExecute calls (rolled back together, committed together). The TransactionManager interceptor now only flushes the session on commit/end and clears it on rollback, and in-transaction ORM queries flush first so they observe their own pending writes (read-your-writes).
ORMPreConfigLoad and ORMPostConfigLoad are now registered as interception points.
Faster ORM boot. Every id and version now tells Hibernate the value that means "not saved yet", so Hibernate no longer creates one throwaway instance of every entity at startup to find out. The per-entity mappings are also joined as text instead of through a DOM merge, and with enableThreadedMapping on (the default) apps with more than 20 entities add the static entity methods in parallel.
The ORM module classloader is read through BoxLang's ModuleRecord.getModuleClassLoader() instead of the deprecated classLoader field.
Entity loads by id use Hibernate's Session.find() instead of the deprecated Session.get( entityName, id ), and managed checks use Session.contains( entity ) instead of the deprecated contains( entityName, entity ). ormReadOnly() still makes those loads read-only.
The native id generator uses the database's own strategy, as bx-orm 1.x did: an identity column on MySQL, MariaDB, SQL Server and Derby, and a sequence on PostgreSQL and Oracle. The sequence is the shared hibernate_sequence with an increment of 1 (or the property's sequence annotation), so databases created by bx-orm 1.x keep working. Before, native always meant identity.
entityNew() only sets keys that are declared properties of the entity (or a parent class); other keys are skipped. The unimplemented ignoreExtras argument is removed (a third argument is accepted and ignored).
proxyLazyLoading has no effect and logs a one-time warning: a lazy to-one association is always loaded through a proxy.
The secondary cache is BoxLang's BoxCache: every Hibernate cache region is a BoxLang cache. A BoxLang cache that already exists with a region's name (for example one defined in boxlang.json) is used as that region, and cacheProvider can name any registered BoxLang cache provider.
Switch annotations can be written as BoxLang annotations without a value, and the switch is on: @persistent, @readOnly, @dynamicInsert, @dynamicUpdate, @mappedSuperClass and @softDelete on an entity, and @persistent, @unique, @notNull, @insert, @update, @readOnly, @optimisticLock, @inverse, @constrained, @missingRowIgnored and @lazy on a property. Before, a valueless @persistent stopped the ORM from starting (String [] cannot be cast to a boolean), and a valueless @softDelete was ignored. An explicit value still wins: @persistent( false ) turns the switch off, and @softDelete( "timestamp" ) and @lazy( "extra" ) keep their meaning.
Criteria like() and ilike() (and c.restrictions.like() / c.restrictions.ilike(), their aliases and notLike()) take an optional third argument, a one-character escape: like( "tags", "%50!%-off%", "!" ) or like( property = "tags", value = "%50!%-off%", escapeChar = "!" ). The two-argument form is unchanged, so cborm's like( property, value ) keeps working. An escape of more than one character raises orm.argument.
onDelete="cascade" on a many-to-one property declares that the database cascades the delete (FOREIGN KEY ... ON DELETE CASCADE). It maps to Hibernate's @OnDelete( action = CASCADE ): the generated schema gets ON DELETE CASCADE, and deleting the parent removes its loaded children from the session instead of failing at flush. Use it when the parent has no ORM cascade and no collection back to the child. onDelete="noaction" is the default; any other value fails at mapping time.
cacheConfig configures the second-level cache regions: a struct of BoxCache properties (maxObjects, defaultTimeout, ...) with an optional regions struct of per-region overrides, a JSON file of the same shape, or an EHCache 2 or 3 ehcache.xml whose settings are mapped to BoxCache properties.
cacheUse and cacheName on a collection property (one-to-many, many-to-many, collection) cache the collection in the second-level cache.
The unsavedValue property annotation on an id is honored: it is the id value that marks an entity as new (not yet saved), for example unsavedValue="0" on an assigned numeric id.
Static entity methods: every entity class gets User::get( 1 ), getOrFail, getAll, read, getReference, findWhere, findWhereOrFail, findAllWhere, first, exists, count, list, executeQuery, criteria / newCriteria, new, firstOrNew, firstOrCreate, deleteWhere and updateWhere, each calling the matching BIF. A static method the entity declares itself is kept, and instances reach them too (user.count()) unless they declare a method of that name. On by default; set ormSettings.staticMethods = false to turn them off. In development (trusted cache off), an edited entity gets its methods back on the next request.
asStream option for ormExecuteQuery() and entityLoad(): return a Java Stream that reads rows from the database as it is consumed, instead of an array. Works with BoxLang closures (.filter(), .map(), .toList()), maxResults, offset and sort orders. Not allowed with unique or an update/delete (orm.argument).
Criteria paginate() includes offset (rows skipped before the page) in its pagination struct.
Case-insensitive HQL names: entity and property names in ormExecuteQuery() HQL resolve in any case (from user where firstname = ?), as BoxLang is case-insensitive. HQL written in declared case costs nothing extra; a wrong-case name is rewritten to its declared case once and the corrected HQL is cached per application. String literals and parameter names are never touched, and a misspelled name still fails with "Did you mean".
Clear ORM errors: every error bx-orm raises is an orm.* typed exception (catch all with catch( "orm" e ), or a family such as "orm.query"). Messages use BoxLang entity and property names (never generated facade class names), say how to fix the problem in detail, carry the context (entity, property, HQL, params, SQL, constraint) in extendedInfo, and suggest the right name for misspelled entities, properties, field types and ormtypes ("Did you mean [name]?"). Covers HQL syntax and unknown names, missing or mistyped query parameters, lazy loads after the session closed, unsaved associations, missing assigned ids, not-null and unique/foreign-key violations, stale (optimistic lock) updates, and wrong arguments to entity BIFs.
ormDiagnostics(): the ORM's state for the current application (status, last startup error, entities per datasource, warnings, key settings, this request's open sessions). Never throws.
Startup validation: duplicate entity names on one datasource are reported with both classes; unknown ormtype values are warned about and listed as possible causes (after Hibernate's own reason) if Hibernate fails to start, while a relationship's collection type (array, struct) is not mistaken for an ormtype; broken startups (bad entity path, fieldtype, cfc or datasource) raise one orm.config error, and the last failure is remembered for later ORM calls and ormDiagnostics().
uniqueFirst option for ormExecuteQuery() and entityLoad(): take the first row of a multi-row result.
Entity inspection BIFs: entityGetName(), entityGetDatasource(), entityGetId(), entityGetMetadata() (cached per ORM application), entityIsDirty() and entityGetDirtyProperties() (Hibernate's own dirty check; no SQL for managed entities), ormIsSessionDirty() and ormGetSessionStatistics().
entityCriteria( entityName ): a fluent query builder. Conditions (cborm names and aliases, not* negation, anyOf/allOf groups, where() shorthands, native sql() with bound params), automatic joins for dotted paths, aliases and with{Association}(), fetch joins, subqueries (exists, isIn, cborm property*/sub*), projections (project(), cborm withProjections()), struct/query/stream results, ordering, paging and query options. Terminals: list, count, exists, get, getOrFail, first, firstOrFail, paginate, simplePaginate, pluck, sum/avg/min/max, each, chunk. Property names are checked while building ("Did you mean"), getSQL()/peekSQL()/logSQL() show the SQL without running it, writeDump() shows the calls, HQL, params and SQL, and cborm's criteria interception points are announced (in the calling request's context, so listeners can use its scopes).
entityCriteria() cborm extras: c.restrictions.* builds condition objects that add(), or(), and() and not() accept (e.g. c.or( c.restrictions.isEq( "role", "admin" ), c.restrictions.isGt( "age", 30 ) )); quantified subqueries subEqAll, subGt/Ge/Lt/LeAll and ...Some, propertyEqAll, propertyGt/Ge/Lt/LeAll and ...Some (x >= all (select ...)); and the SQL log: logSQL( label ) appends { type, sql } to getSqlLog(), startSqlLog( returnExecutableSql, formatSql ) / stopSqlLog() / canLogSql() / getSqlLoggerActive().
entityCriteria() cborm 4/5 compatibility, found by running ContentBox: joinTo() / createAlias() (and innerJoin/leftJoin/rightJoin/fullJoin) take a withClause (a restriction or a closure) rendered as the join's on clause; resultTransformer( c.DISTINCT_ROOT_ENTITY ) with the ROOT_ENTITY, DISTINCT_ROOT_ENTITY, ALIAS_TO_ENTITY_MAP and PROJECTION constants; order() / list( sortOrder ) accept a projection alias; a property of a subclass entity works on its base entity; and the class pseudo-property compares the entity type by discriminator value or entity name (isEq( "class", "Entry" )).
entityCriteria() cborm 5 compatibility, found by running TimeBox: withProjections( sqlProjection = { sql, alias, property } ) (or an array of them) adds a native SQL column; sql() and sqlProjection read the Hibernate 5 aliases cborm users wrote by hand (this_.col for the root, <alias><n>_.col for a joined alias) as well as {alias}.col; a struct value that is an array (deleteWhere( id = [ 1, 2 ] ), where( { id : [ 1, 2 ] } )) is an in list; count() drops the builder's projections afterwards, as cborm 5 did, so c.count() then c.list() returns entities; and a subclass entity (joined or single table) reports the id it inherits from its parent, so entityGetId() and cbvalidation's UniqueValidator work on it.
orm.notFound error type for getOrFail() / firstOrFail().
Soft delete: entity softDelete="true" (boolean deleted column), "active" (inverted active column) or "timestamp" (deletion date), with softDeleteColumn to rename the column. entityDelete() marks the row, and every load, query and association skips deleted rows (Hibernate @SoftDelete, carried by the generated facade).
Automatic timestamps: property autoTimestamp="create" (set on insert) or "update" (set on insert and every update), via Hibernate @CreationTimestamp / @UpdateTimestamp.
entityLoadOrNew(), entityLoadOrSave(), entityLoadOrFail() and entityLoadByPKOrFail(): load by id or filter, or return a new unsaved entity, save a new one, or raise orm.notFound.
entityEvict( entityOrArray ): remove entities from the session. entityGetReference( name, id ): a reference without a SELECT.
Pessimistic locking: entityLock( entity, mode, options ), entityLoadByPK( name, id, { lock } ), criteria lock() and ormExecuteQuery( ..., { lock } ), with modes read, write, force and timeout / skipLocked options. Locks need transaction{}.
Read-only loading: ormReadOnly( closure ), entityLoadReadOnly() and a readOnly option on entityLoad() and entityLoadByPK().
Criteria bulk statements: updateAll( { prop : value } ) and deleteAll() run one HQL statement and return the row count (no events or cascades; loaded entities are not refreshed).
entityLoadByPK( name, [ ids ] ): load several entities in one batched query; the array keeps the asked order, with null for missing ids.
entitySave() and entityDelete() take one entity or an array, and { flush : true } to flush right away.
defaultSort entity annotation (defaultSort="lastName, firstName desc"): the order entityLoad() and criteria use when none is given. Checked at boot.
Functions in criteria paths: isEq( "year(createdDate)", 2025 ), order( "lower(name)" ), nested calls, literals and cast().
Named SQL functions: ormSettings.sqlFunctions = { name : "sql(?1)" } (or { sql, returns }) registers SQL templates for HQL and criteria; ormGetSQLFunctions() lists them.
postCommit( entity, action ) event on the entity and the global event handler, fired once a write is committed (never for rolled-back writes).
useDBForMapping=true (Adobe ColdFusion compatibility): at boot, untyped properties get their ormtype from the column type and entities without an id get it from the table's primary key.
entityToStruct( entityOrArray, options ): entities as structs, mementifier-compatible (this.memento defaults, excludes, never-include, mappers, defaults, profiles), with dotted association paths, cycle safety and ISO 8601 dates.
entityLoadAsStruct( name, idOrFilter, includes, options ) and criteria asStruct( includes ): the same structs read with projection queries, without loading entities. Getters you write for a property are honored in all three, so they shape the output the same way.
Event veto: a preInsert, preUpdate or preDelete handler (on the entity or the global eventHandler) that returns false cancels the operation. Vetoing the insert of a database-identity entity raises orm.event.veto, since Hibernate cannot skip that insert.
POJO-facade entity representation (now the only representation): each entity maps to a generated Java facade whose accessors delegate to the BoxLang instance, unlocking uuid (and other) id generators, composite ids, byte[], and full metamodel access.
Facades are namespaced per ORM application, so same-named entities in different apps do not collide.
Composite (multi-column) primary keys and entity inheritance (single-table + joined) in the facade representation.
Associations and lazy proxies in the facade representation
Modern Hibernate 7 mapping.xml output via MappingXMLWriter
Value/element collections (fieldtype="collection") as a JPA <element-collection>: array (BAG) and struct/map (MAP).
New core postNew ORM event, fired by entityNew() on the entity's own postNew( entity, entityName ) and the global eventHandler. (Hibernate has no instantiate event; previously only cborm offered ORMPostNew.)
JMH benchmark suite (src/jmh) for entity CRUD, bulk hydration, and cold boot, plus a jmhCompare task benchmarking Hibernate 5 vs 7.
Standalone boot + CRUD smoke tests for Derby, PostgreSQL, and MariaDB (Postgres/MariaDB gated by env vars).
ORM manifest boot cache (ormManifest setting: off/auto/trust). In auto the resolved boot model (per-entity metadata + mapping) is written to .bxorm/manifest-{app}.json after each boot; in trust the app boots straight from that manifest with zero entity discovery, parsing or mapping generation (integrity-checked, fail-closed). Aimed at cold-start-heavy and large-entity apps. Off by default.
The combined Hibernate mapping.xml is now fed to Hibernate in-memory (addInputStream) instead of via a temp file, removing a write+read on every boot.
Pre-generated ByteBuddy facade bytecode is cached to .bxorm/facades-{app}.jar in auto mode and injected in trust mode, so production boots skip facade code generation.
bxorm CLI (boxlang module:orm <verb>) to inspect the .bxorm/ boot cache: info, validate, entities, entity <name>, mappings, clear, version, help. Reads the manifest only; generate (below) or one ormManifest="auto" boot builds it.
Several ORM applications can share one .bxorm/ folder (sub-applications under the same root): each application's boot cache files carry its name (manifest-{app}.json, manifest-{app}.sha256, facades-{app}.jar, where {app} is the application name slugified like BoxLang's slugify(): My Shop becomes my-shop). The manifest records its application, and a trust boot refuses a manifest written for another application. The bxorm CLI takes --app=<name> to pick an application (info and validate cover every application when it is left out) and clear --all removes the whole folder.
ormManifestLocation ORM setting (Application.bx → this.ormSettings): choose where the .bxorm/ boot cache is stored. Blank (default) keeps it at the application root; a relative path resolves against the app root, an absolute path is used as-is. The folder name stays .bxorm; only its parent moves. Mirrors the bxorm CLI --dir flag.
ormManifest="auto" now starts a source watcher over the entity paths: editing an entity marks the ORM application for reload, and the next request reloads it automatically (no manual ormReload()). Generated *.orm.xml and the .bxorm/ cache are ignored so a reload's own writes never loop. The watcher is stopped on shutdown/reload and degrades gracefully when the runtime has no watcher service.
boxlang module:orm generate builds the .bxorm/ boot cache (manifest and facades-{app}.jar) from the command line, with no server, no database and no application start, so a Docker build or CI step can ship a trust-ready image: boxlang --bx-config runtime/boxlang.json module:orm generate. It runs the Application.bx/.cfc pseudo-constructor only (empty cgi, url, form and cookie scopes are provided), never onApplicationStart(). --dir sets the app root.
ORM observability events for tools that want to watch ORM activity without reflecting into Hibernate. onORMQuery is announced after each JDBC statement with sql, kind, elapsedNanos, rows, datasource, appName, hql, entityName, error and, optionally, params. onORMFlush reports insert, update and delete counts per flush, and onORMException reports failures. Nothing is wrapped or built when there are no listeners. See docs/observability-events.md.
announceQueryParams ORM setting (default false) to include bound parameter values in onORMQuery.
generateStatistics ORM setting (default false), plus ORMService.getStatistics( appName ) and ORMService.setStatisticsEnabled( appName, enabled ) for a plain-struct view of Hibernate statistics.
BLMODULES-318 Inside transaction{}, queryExecute(), bx:query and qb did not see ORM writes made earlier in the transaction: entitySave() followed by a SQL select or update found 0 rows, with autoManageSession on or off, because only ORM queries flushed the session first. The ORM now flushes the open session of the transaction's datasource before every query on it (BoxLang's preQueryExecute). The flush is not a commit: a rollback still discards the writes. A query outside a transaction, on another datasource, or run from an entity event during a flush does not flush, and no session is opened for it. A query after a nested transaction{} block now sees the block's writes too.
BLMODULES-319 A criteria query with a condition on a collection (entityCriteria( "User" ).isEq( "roles.id", 1 ), or cborm's newCriteria()) failed on PostgreSQL when the entity had a json column (could not identify an equality operator for type json), and when it was sorted by a joined property (for SELECT DISTINCT, ORDER BY expressions must appear in select list). It used select distinct over every column of the entity; the same failed for SQL Server text and Oracle CLOB columns. Such queries now match the entity's id in a subquery, so the database never compares the other columns, and maxResults(), firstResult() and paginate() still count entities. Paged queries got faster too (about 1.5 to 2 times on MariaDB with 20,000 rows). asStruct( includes ) no longer returns one row per matching collection element. Sorting by a property of a collection (order( "roles.name" )) is now an orm.argument error, since an entity has many values for it.
BLMODULES-320 A transaction{} in a request or thread where the ORM is not enabled, for example a thread started with runThreadInContext() that does not copy ormEnabled (as cbq's queue workers do), failed with orm.notEnabled just because bx-orm was installed. The transaction events now act only on the ORM context and the Hibernate sessions that ORM work in that request or thread has already opened. A transaction that runs only native queries no longer opens a Hibernate session for every ORM datasource.
On a fieldtype="collection" property, removeX( value ) no longer fails with a ClassCastException, hasX( value ) returns false for a value that is not in the collection (it returned true whenever the collection was not empty), and hasX( key ) on a loaded type="struct" collection no longer fails with a ClassCastException.
A preInsert or preDelete handler that vetoes the operation no longer fires postInsert / postDelete and postCommit for it. Hibernate calls its post-event listeners even after a veto, so a vetoed delete announced a committed delete for a row that was never removed.
An entity reached through no mapping (a relative entityPaths folder in a CLI script, boxlang app.bxs, or in module:orm generate) is named after its file again. BoxLang named its class after the whole folder path, so the entity was called tmpappmodelsUser instead of User and loads by name failed; the boot cache recorded the same wrong name.
In off and auto mode, switch annotations written without a value (@persistent, @unique, ...) now read true in the entity class's metadata (getClassMetadata()), as they already did after a trust boot, so code that reads the metadata as booleans works.
dynamicInsert and dynamicUpdate on an entity work again. Hibernate 7 ignores them in the generated mapping.xml, so they had no effect in 2.0; they are now put on the generated entity class as Hibernate's @DynamicInsert and @DynamicUpdate. selectBeforeUpdate has no Hibernate 7 equivalent: it still has no effect, and an entity that sets it now logs a warning.
constrained given as a boolean (@constrained( true )) no longer fails the mapping with a ClassCastException.
Criteria like() and ilike() treat a backslash as the escape character again on MySQL and MariaDB, PostgreSQL, CockroachDB and H2, as bx-orm 1.x and cborm 5 did. Hibernate 7 renders like ... escape '' there when no escape is given, and an empty escape turns the escape character off, so like( "tags", "%50\%-off%" ) matched nothing. The default escape on those databases is now a backslash, so \%, \_ and \\ match literally. Other databases (Oracle, SQL Server, Derby, DB2, ...) are unchanged: no escape clause is rendered, so the database default applies. MySQL with NO_BACKSLASH_ESCAPES is unchanged too. Pass an explicit third argument to use another escape character on any database.
BOX-178 After a trust boot, entity classes kept their raw annotations, so code reading entity metadata saw a different entity than after an off or auto boot. ColdBox's populate() then failed on every relationship (The class [models.users.Employee] could not be found), because it reads the entityName that discovery adds. A trust boot now publishes the manifest's normalized metadata (entityName, table, default fieldtype and ormType, normalized association types, inherited classes included) onto each entity class at boot, so getClassMetadata() and getMetadata() return the same values in every mode.
ormGetSessionFactory().getMetamodel().getAllEntityNames() and ormGetSession().getEntityName( entity ) returned the generated facade class names (...EmployeeFacade) instead of the entity names. They return the entity names again (Employee), as in bx-orm 1, and the raw API accepts those names back.
BLMODULES-306 <cfquery dbtype="hql"> / <bx:query dbtype="hql"> and queryExecute( hql, params, { dbtype : "hql" } ) run HQL and return the same array as ormExecuteQuery(). Before, dbtype was ignored and the HQL ran as SQL, returning a query. <cfqueryparam> binds positional parameters (cast to its cfsqltype), and ormoptions, maxrows, timeout, datasource and result apply.
boxlang module:orm verbs that fail (for example validate on a missing or corrupt cache) now exit non-zero, so CI steps can rely on them. Before, every verb exited 0.
entityCriteria() on a base entity failed (User has no property [costRate]) for a property that several subclass entities declare, such as costRate on both Employee and Contractor under User: Hibernate 7 refuses the ambiguous name. It is now read as coalesce(treat(x as Employee).costRate, treat(x as Contractor).costRate), so projections, conditions and ordering use each row's own value (Hibernate 5 silently read only one subclass's column, so the other subclass's rows were null). When the subclasses declare it with different types, or a path continues through it, the error is orm.property.ambiguous, naming the subclasses. Found by TimeBox's daily timesheet (GET /api/v1/users with a propertyList).
HQL rows of select new map( ... ), select new list( ... ) and tuples (select a, count(b)) held Hibernate facades instead of BoxLang entities, so calling an entity method on them failed (No such method [getSiteID] in cbEntryFacade).
Static entity methods were not added to .cfc entities: they asked for a cfc class resolver, which BoxLang does not have.
Hibernate's end-of-transaction work (second-level cache updates, bulk update/delete clean-up) never ran, because the ORM rides the BoxLang transaction and Hibernate never saw it end. It now runs when a transaction{} ends or rolls back, and before a session closes, so cache entries are released on time and Hibernate no longer warns HHH90010101 / HHH90010108 on close.
The ORM no longer creates any entity while it starts. Hibernate 7 built one throwaway instance of an entity whose id was assigned, had a default, or that had a version property, to find out what a new entity looks like. That ran the entity's init() during onApplicationStart, before the application was ready, so an init() that needs it (for example a cborm ActiveEntity reading application.wirebox before ColdBox loads) made ORM startup fail with The key [WIREBOX] was not found. bx-orm now tells Hibernate the unsaved value of every id and version, so new and existing entities are told apart exactly as before without creating one.
entityLoad() with a cachename option did not cache unless cacheable : true was also passed.
The sqlScript setting was never read, so the script never ran after dbcreate created the tables.
The cacheConfig struct was ignored for the default BoxCache provider.
The mapping CLI's --debug flag had no effect.
entitySave() of a new entity with a database-generated id (generator="identity" or "native" on MySQL) sets the id right away again, inside a transaction{} too. Hibernate 7 had delayed the insert until the flush, so getId() returned null.
The entity-level where annotation was never read, so it had no effect; it now restricts every load and query of the entity.
Optimistic-locking <version> columns now work end-to-end.
text/clob properties map to TEXT/LONGTEXT (via <lob/>) instead of an in-row varchar, avoiding MySQL row-size failures.
An inverse one-to-many with no explicit fkcolumn is emitted as a mapped-by collection instead of synthesizing a join table.
binary/byte[] properties are mapped and persisted (previously silently skipped).
A capitalized association property name (e.g. Client) no longer breaks boot; mapped-by is decapitalized to match the facade accessor.
A discriminated single-table subclass with a <secondary-table> now persists and deletes its own columns (emits owned="true").
A primary-key load (entityLoadByPK, session.get) of a session-managed entity no longer returns null.
removeX() on a to-many removes by identity/equality, not by the owner's id property names.
A to-many association can be structurally modified while iterating its getter
Updating an entity with an association/collection no longer double-fires preUpdate/postUpdate.
Hardened entityLoad() filter queries against HQL injection (the order by property is validated against the entity's properties).
entityLoad() / ormExecuteQuery() accept a primary key or entity instance for a to-one association filter/parameter, resolving to a managed reference before binding.
ormExecuteQuery() list parameters bound to an association resolve every element, not just the first.
entityLoadByExample() builds predicates from the inheritance-aware property set and excludes ids, version, and associations.
entitySave() on a detached entity leaves the passed-in object live and carrying generated ids/event changes (Hibernate 7 removed saveOrUpdate()).
Date/time properties retain millisecond precision (DateTimeConverter maps to java.sql.Timestamp).
Removed a stale fieldtype="collection" … not yet supported warning that logged on every value/element collection even though collections are now supported.
Inherited to-many associations now get the stable-snapshot getter, so parent.getChildren().each( c => parent.removeChild( c ) ) is safe for a collection declared on a persistent parent entity (previously only associations declared directly on the entity were protected).
removeX() on an unmanaged (transient) collection now prefers an exact identity match, so a distinct-but-equal transient element is not removed by mistake.
An owning one-to-many without fkcolumn reuses the target's back-reference foreign key instead of creating a join table.
A struct-typed (type="struct") one-to-many/many-to-many maps its key (structKeyColumn/structKeyType) and round-trips by key.
A fieldtype="timestamp" version property boots and is stamped on save.
Hibernate isolated work (e.g. sequence/table id allocation) inside a transaction{} runs on its own pooled connection, so it can no longer commit or roll back the surrounding BoxLang transaction mid-flight.
duplicate() of an ORM entity produces an independent copy that saves its own state instead of sharing the original's Hibernate facade.
ORM BIFs no longer fail with a NullPointerException when the application is not ORM-enabled or the ORM failed to start; they raise orm.notEnabled / orm.notReady with the reason.
Entity lookup no longer fails with "No entities found for datasource" when every entity lives on a non-default datasource.
A detached entity bound as an ormExecuteQuery() or entityLoad() filter parameter resolves correctly (the generated facade name no longer leaks into the lookup).
ormExecuteQuery() now applies the cacheable, cacheName and timeout options (they were ignored), and entityLoad() applies cacheName as the query cache region.
entityLoad() with ignorecase no longer wraps numeric or date sort properties in lower().
ormFlush( datasource ) flushes that datasource's session instead of the default one.
An association parameter given as an id (ormExecuteQuery(), entityLoad()) no longer fails with "cannot be used as ...Facade" when the session already holds a lazy proxy for that row.
A failed flush at the end of a request still closes the request's ORM sessions.
The uniquekey and index property annotations create their unique constraints and indexes again (lost in the move to mapping.xml). Properties sharing a name form one multi-column constraint or index; both accept a comma-separated list, and both work on many-to-one foreign keys.
BL-2739 - generator="identity" no longer fails on PostgreSQL when dialect is set explicitly and the table name is on the reserved-word list (comment, collection, release, synonym, user, ...). Hibernate read the new key back with select currval('"comment"_id_seq'), which PostgreSQL rejects with invalid name syntax. An explicit PostgreSQL dialect now tells Hibernate the driver returns generated keys, as auto-detection already did. Set hibernate.jdbc.use_get_generated_keys in hibernateProperties to override it.
<cfquery dbtype="hql"> / <bx:query dbtype="hql"> and queryExecute( hql, params, { dbtype : "hql" } ) run HQL and return the same array as ormExecuteQuery(). Before, dbtype was ignored and the HQL ran as SQL, returning a query. <cfqueryparam> binds positional parameters (cast to its cfsqltype), and ormoptions, maxrows, timeout, datasource and result apply.String cannot be cast to Integer. entityLoad() filters and HQL parameters (ormExecuteQuery(), dbtype="hql" queries, untyped <cfqueryparam>, list parameters) convert the value to the property's type, so a form or URL id such as "1" works. Integer types only take whole numbers, and a value that cannot be converted is passed to Hibernate unchanged.fieldtype="collection" (Adobe CF ORM "collection mapping") is now supported: a type="array" property becomes a Hibernate <bag> and a type="struct" property a <map> of simple values stored in their own table (table, fkcolumn, elementcolumn, elementtype, plus structkeycolumn/structkeytype for maps, orderby, lazy, batchsize). Previously the property was dropped from the mapping with only a warning in orm.log: the getter returned null and values set on it were never flushed. A collection without elementcolumn or fkcolumn now fails at mapping time instead of being ignored. The generated hasX( value ), addX( value ) and removeX( value ) helpers accept the scalar values of such a collection, and fieldtype is matched case-insensitively. Writing a BoxLang struct to a map collection (type="struct", on a to-many association as well) no longer fails with a ClassCastException on the struct's Keys: the property getter hands Hibernate a map keyed by the original key values.onORMQuery is announced after each JDBC statement with sql, kind, elapsedNanos, rows, datasource, appName, hql, entityName, error and, optionally, params. onORMFlush reports insert, update and delete counts per flush, and onORMException reports failures. Nothing is wrapped or built when there are no listeners. See docs/observability-events.md.announceQueryParams ORM setting (default false) to include bound parameter values in onORMQuery.generateStatistics ORM setting (default false), plus ORMService.getStatistics( appName ) and ORMService.setStatisticsEnabled( appName, enabled ) for a plain-struct view of Hibernate statistics.ORMPreConfigLoad and ORMPostConfigLoad are now registered as interception points.generator="identity" no longer fails on PostgreSQL when dialect is set explicitly and the table name is on the reserved-word list (comment, collection, release, synonym, user, ...). Hibernate read the new key back with select currval('"comment"_id_seq'), which PostgreSQL rejects with invalid name syntax. An explicit PostgreSQL dialect now tells Hibernate the driver returns generated keys, as auto-detection already did. Set hibernate.jdbc.use_get_generated_keys in hibernateProperties to override it.entityToQuery() no longer adds columns for relationship properties (one-to-one, one-to-many, many-to-one, many-to-many). Previously these columns were present but always null. The result query now contains no relation data, matching Adobe ColdFusion and Lucee. Code reading those always-empty columns must be updated.entityIsAttached() to check whether an entity is attached to the ORM session for its datasource.ormSettings.hibernateProperties setting: a flat struct of raw Hibernate property name/value pairs applied directly to the Hibernate Configuration, letting applications tune settings like hibernate.connection.release_mode without a custom Hibernate config file.ormSettings.ormConfig setting as a path to a hibernate.properties-formatted file, applied the same way as hibernateProperties (a conflicting key in hibernateProperties takes precedence). The hibernate.cfg.xml file format is not yet supported.ormSettings.dialect = "SQLite" now resolves to org.sqlite.hibernate.dialect.SQLiteDialect, provided by the new com.github.gwenn:sqlite-dialect dependency (org.hibernate:hibernate-community-dialects, which houses the official SQLite dialect, is only published for Hibernate 6+ and is not available while this module is pinned to Hibernate 5).uuid2 ORM generator.entityToQuery() now includes inherited persistent properties (e.g., from a persistent parent entity) in query columns. Property collections internally use LinkedHashSet to prevent duplicate properties across the inheritance chain.GRADLE_VERSION to 9.6.1 to match the Gradle wrapper and fix NoSuchMethodError with Shadow plugin 9.6.1uuid) so mixed-case declarations are handled correctly.BoxRuntimeException listing valid built-in generators.ORMConnectionProvider to avoid noisy logs on every connection acquisition..agents/skills and custom skills under .agents/skills-custom.agents/skills-custom for ORM configuration and troubleshooting.AGENTS.md with a pointer from CLAUDE.mdClassCastException when saving entities with ormtype="float" properties containing Integer values (e.g., default="0"). Added missing FloatConverter and registered it in HibernateXMLWriter.missingRowIgnored annotation not being applied to collection relationships.autoManageSession is enabled.one-to-many associations when inversejoincolumn attribute is specifiedscale annotation not properly cast to a string in ClassicPropertyMeta.SessionFactory instances, preventing stale session/factory references from blocking garbage collection after every ORMReload().SessionFactoryBuilder now wipes the BootstrapServiceRegistry when buildSessionFactory() throws, so the registry is not orphaned on the failure path.ORMContext is removed from the JDBC context before rebuilding, and a fresh one is eagerly installed after the new app is live, eliminating null-window races for concurrent callers.EntityTuplizer and related components now obtain the box context safely when executing in a non-request thread.dbdefault annotation not properly cast to a string in ClassicPropertyMeta.interceptorService.announce() calls on hot code paths (entity instantiation, config load) are now guarded with hasState() checks and use lazy Struct suppliers, avoiding unnecessary struct allocation when no listeners are registered.ORMConfig now receives and threads the IBoxContext through process() and getAppDefaultDatasource() so the correct application datasource is resolved in all execution contexts.ORMService.reloadApp() now performs an atomic put-and-swap of the new/old ORMApp in the registry to minimize the disruption window for requests running concurrently with a reload.v1.11.x and aboveautoGenMap configuration setting is now deprecated in favor of generateMappings. Same function, different name. See BLMODULES-119 for details.generateMappings=false (aliased as autoGenMap for backwards compatibility) to disable automatic mapping generation and require manual mapping files.v1.11.x and abovelazy and defaultBatchSize to provide compat implementationsautoManageSession is falseEntityTuplizer.getEntityMode() for relationship getterstable, schema, and catalog annotations for joined subclasses.mappedSuperClass issues with 3+ levelstinyint and tinyinteger ORM types - Resolves BLMODULES-59dataType annotation on version properties - Resolves BLMODULES-51column and fkcolumn - Resolves BLMODULES-48elementType,elementColumn annotations - Resolves BLMODULES-46structkeytype or structkeycolumn are ignored - See BLMODULES-45AttributeConverter on identifier properties - Resolves BLMODULES-44ORMGetHibernateVersion() stays accurate - See a8c7c16lazy property annotationdate property type - See c6ec8a2skipCFCWithError setting - Resolves BLMODULES-37get are returning proxies instead of the entity - Resolves BLMODULES-35No significant changes.
uniqueOrOrder to string in EntityLoad BIF - See 98f6734uniqueOrOrder argument in EntityLoad BIF - See 394d9banot-null annotation usage on one-to-one relationships - See c512848has methods are overriding declared methods in ORM entities - Resolves BLMODULES-31x-to-one generated hasX() methods are not returning the correct values - Resolves BLMODULES-32
$
box install bx-orm