feat: findBy repository shortcuts (Java 21) and reified Query results (Kotlin)#161
Merged
Merged
Conversation
… (Kotlin)
Java 21 API:
- Add findBy/getBy/findAllBy/findRefBy convenience default methods to
EntityRepository and ProjectionRepository (since 1.12).
- Make template-based groupBy/having/orderBy public on QueryBuilder.
Kotlin API:
- Add reified extensions on Query: resultList<T>(), singleResult<T>(),
optionalResult<T>(), resultStream<T>() and resultFlow<T>(), making the
advertised orm.query { }.resultList<User>() syntax compile (since 1.12).
Docs & skills:
- Update Kotlin examples in the next docs to the reified syntax.
- Fix Kotlin snippets that did not compile (error-handling.md used
Java-style accessors on QueryBuilder) or were not parameterized as
claimed (security.md interpolated into a plain string instead of a
template lambda).
- Skills accuracy pass across the storm-* skills; document the new
reified extensions in storm-sql-kotlin and storm-query-kotlin.
- Regenerate llms-full.txt from the current docs.
Other:
- Update developer email in the parent POM.
Drop orderByDescending/limit from the repository aggregate example and rename topCities(country, limit) to usersPerCity(country); align the Show SQL panel accordingly.
Show plain SQL mapped to an ad-hoc data class (CityCount) before the templated query, and add the passed-through SQL to the Show SQL panel.
Lead with plain SQL the QueryBuilder can't express (RANK() OVER), filtered by a $country bind variable, mapped to an ad-hoc data class. Annotate bind variables inline with SQL comments in both queries.
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.
Description
New API conveniences for the next release (1.11.7) plus a documentation/skills accuracy pass.
Java 21 API (storm-java21):
findBy/getBy/findAllBy/findRefBy/findAllRefBy/getRefByconvenience default methods onEntityRepositoryandProjectionRepository(@since 1.11), mirroring the Kotlin API.groupBy/having/orderByonQueryBuilderare nowpublic(wereprotected).Kotlin API (storm-kotlin):
Query:resultList<T>(),singleResult<T>(),optionalResult<T>(),resultStream<T>(),resultFlow<T>()(@since 1.11), each delegating to theKClass-based methods. This makes the syntax advertised on the front page and docs —orm.query { ... }.resultList<User>()— actually compile. They coexist with the untypedresultListproperty (property access still resolves to the member).Landing page:
usersPerCity(country)(no orderBy/limit).RANK() OVER), filtered by a$countrybind variable and mapped to an ad-hoc data class; bind variables are annotated with inline SQL comments. The Show SQL panel mirrors both queries.Docs (next) & skills:
sql-templates.md,hydration.md).error-handling.mdused Java-stylegetSingleResult()/getOptionalResult(User::class)onQueryBuilder(nowsingleResult/optionalResultproperties);security.mdinterpolated into a plain string passed toquery(String)— not parameterized as claimed — now a template lambda.storm-*skills; skills no longer reference concrete Storm versions.llms-full.txtregenerated from the current docs (was stale since March, hence the large diff).Other:
@since 1.12tag onTransactionContext(that API shipped in 1.11.4).The 1.11.6 versioned docs intentionally keep the
resultList<User>()syntax and are left untouched; they become accurate when 1.11.7 is released.Related Issue
None.
Type of Change
Checklist
mvn verify)Module(s) Affected
storm-java21, storm-kotlin, storm-core (javadoc only), website (landing page, docs, skills, llms-full.txt), parent POM
Breaking Changes
None. All API additions are backward compatible; widening
groupBy/having/orderByfromprotectedtopublicis source- and binary-compatible.