Add managed ORM sessions and relationships to client and backend - #5885
Conversation
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
|
Compared 172 screenshots: 172 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 172 screenshots: 172 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 172 screenshots: 172 matched. Benchmark ResultsDetailed Performance Metrics
|
|
Compared 172 screenshots: 172 matched. |
|
Compared 172 screenshots: 172 matched. |
|
Compared 193 screenshots: 193 matched. |
✅ ByteCodeTranslator Quality ReportTest & Coverage
Benchmark Results
Static Analysis
Generated automatically by the PR CI workflow. |
|
Developer Guide build artifacts are available for download from this workflow run:
Developer Guide quality checks: |
|
Compared 157 screenshots: 157 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Cloudflare Preview
|
|
Compared 223 screenshots: 223 matched. |
|
Compared 166 screenshots: 166 matched. Benchmark Results
Detailed Performance Metrics
|
|
Compared 150 screenshots: 150 matched. |
|
Compared 155 screenshots: 155 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
|
Compared 154 screenshots: 154 matched. Benchmark Results
Detailed Performance Metrics
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61c0ce97e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ebf3bb442c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea81ddf795
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94c8deb6b9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be329a2a4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7be9d1ce88
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75701f0f1b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a347472322
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3934a43576
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdb89f5aa0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4117450402
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| check(); | ||
| EntityModel owner = model(entity.getClass()); | ||
| Relationship relation = owner.relationships()[owner.relationIndex(field)]; | ||
| autoFlush(); |
There was a problem hiding this comment.
Validate relationship-count identifiers before flushing
When count() receives a detached owner with a null, incomplete, or otherwise invalid persisted identifier, this call flushes every pending managed change before owner.keyValues(id) rejects the request. That can execute writes and lifecycle callbacks—or mark the transaction rollback-only because of an unrelated pending failure—even though the requested count was invalid; resolve and validate the identifier before calling autoFlush() in both runtime copies.
Useful? React with 👍 / 👎.
| Entry entry = entries.get(entity); | ||
| if (entry == null) { | ||
| throw new PersistenceException("remove requires a managed entity"); |
There was a problem hiding this comment.
Resolve detached targets while collecting removal cascades
When a managed owner points to a detached target with a complete identifier, normal flush validation explicitly accepts that relationship, but removing the owner through a CascadeType.REMOVE or orphan-removal association reaches this lookup and rejects the target solely because the exact object is absent from entries. This also prevents canceling a fresh owner when its REMOVE-only child is transient. Resolve persisted cascade targets by identifier (and ignore unsaved targets whose owning insert is being canceled) rather than requiring every referenced object to already be managed.
Useful? React with 👍 / 👎.
The existing ORM handles basic scalar CRUD but cannot manage an object graph as a unit of work. This change adds managed persistence to the client SQLite ORM and backend ORM through
EntityManager.openSession(), with matching CN1 APIs and build-time metadata on both runtimes.Add session identity, dirty checking, transactional flush, merge/refresh/detach, eager and lazy associations, cascades, orphan removal, optimistic version checks, backend pessimistic row locks, atomic increments, relation counts, and generated identifiers.
Add composite and embedded IDs, embedded values, mapped superclasses, single-table polymorphic inheritance, converters, lifecycle callbacks, ordered lists, entity maps, and scalar element collections.
Add relationship-aware builder queries and a documented JPQL subset with joins, projections, aggregates, subqueries, and bulk mutations. Schema creation includes managed mappings and handwritten legacy definitions; validation checks mapped columns and keys.
Enhance public-field association access at build time, including dependency callers, without runtime proxies. Preserve newly compiled application classes when refreshing dependency overlays. Generated serializers reject unloaded associations.
Keep legacy scalar DAO behavior and give generated client DAOs a separate instance per manager. Document session usage, migration requirements, and supported boundaries in the developer guide.
Keep documented application contracts in
com.codename1.orm.session; move generated metadata, enhancement hooks, SQL adapters, DAO factories, and execution classes undercom.codename1.impl.orm. Place the 31 new mapping annotation types incom.codename1.annotations.db, preserving the existing annotation package names.Preserve standard Javadoc fragments for documented method type parameters in the Hugo API pages. Repair the core test fixtures that leaked touch-device state and raced the Vault prompt latch.
Validation
Core compilation uses Java 8; tests were exercised on Java 8, 17, and 21. The standalone Hugo doclet uses Java 25.
git diff --checkpass.Local focused reactor runs used
-Dmaven.antrun.skip=true; native API compilation was checked separately. This is compile validation, without translated executable or device validation. Hosted CI runs separately on the pushed commit.Supported scope and remaining limits
This is a CN1 managed persistence API, with public-field mappings and a defined JPQL subset. Getter/setter mappings, property-backed associations, joined/table-per-class inheritance, embeddable element collections, independently stored entity-map keys, nested fetch graphs, and mixed entity/scalar projections remain unsupported. Some collection fetch patterns still use individual queries. Existing schemas require explicit migrations, including legacy client text-char columns when moving to managed numeric UTF-16 storage.
MySQL/MariaDB SQL paths are implemented but were not tested against a live server. Native-device execution also remains unverified.