Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Obsidian ORM Replace ActiveJDBC
Overview
This PR replaces ActiveJDBC with Obsidian's native ORM. No more bytecode instrumentation, no more Maven plugin to configure — the ORM integrates directly into the framework lifecycle and supports MySQL, PostgreSQL and SQLite.
Changelog v3.0.0
New — Native ORM
HasOne,HasMany,BelongsTo,BelongsToMany,HasManyThrough,MorphOne,MorphMany,MorphTo.with()— eliminates N+1Blueprint(MySQL, PostgreSQL, SQLite)Paginatorchunk()@Cacheable— InMemory or RedisSecurity & stability
finallyinRouteHandlerguarantees connection close even on exceptioninsertAll()wrapped in transaction — automatic rollback on partial failurewhereIn([])— empty list generates1 = 0instead of crashing with invalid SQLwhereNotIn([])— empty list is a no-opforPage(0)— throwsIllegalArgumentExceptioninstead of generating a negative offsetupdate({})— clean short-circuit, returns 0 without touching the DBrequireWhere()— optional guard against full-tableupdate/deletePerformance
BelongsToMany.eagerLoad()— 1 JOIN instead of 2 queriesresultSetToList()— initial capacity onArrayListandLinkedHashMapConcurrentHashMap)@Cacheable(ttl = 300)— PK and query cache, auto-invalidation onsave()/delete()Migration Guide — ActiveJDBC → Obsidian ORM
1. Dependencies
Remove from
pom.xml:Also remove the instrumentation plugin from the build if present. The
obsidian-coredependency now covers the ORM.2. Models
3. Querying
4. Persistence
5. Connections & transactions
ActiveJDBC requires
Base.open()/Base.close(). The Obsidian ORM manages the connection lifecycle automatically viaDatabaseMiddleware— nothing to do in controllers.For transactions:
DB.withConnection()is unchanged — used in LiveComponents to explicitly open a connection outside the HTTP lifecycle:6. Cache (new)
For frequently read models, add
@Cacheable:Cache is automatically invalidated on
save()anddelete(). Manual flush:7. Quick reference
@Table@Table@IdName("col")primaryKey() { return "col"; }extends Modelextends ModelgetString / getInteger / getLong / getBooleanset(key, value)saveIt()save()orsaveIt()delete()findById(id)Model.find(Cls.class, id)findFirst("col = ?", v)Model.where(Cls.class, "col", v).first()findFirst("a = ? AND b = ?", x, y).query().where("a", x).where("b", y).first()findAll().load()Model.all(Cls.class)where("col = ?", v).load().query().where("col", v).get()where("1=1 ORDER BY col ASC").orderBy("col", "ASC")Base.open() / close()Base.openTransaction()DB.withTransaction(() -> {})DB.withConnection()Tests