-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix some defects in repositories doc #9319
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,7 @@ This really isn't as bad as it sounds; overuse of lazy fetching is associated wi | |
A future release of Jakarta Data will feature repositories backed by Jakarta Persistence stateful persistence contexts, but this functionality did not make the cut for Jakarta Data 1.0. | ||
==== | ||
|
||
The second big difference is that instead of providing a generic interface like `EntityManager` that's capable of performing persistence operations for any entity class, Jakarta Data requires that each interaction with the database go via a user-written method specific to just one entity type. The method is marked with annotations allowing Hibernate to fill in the method implementation. | ||
The second big difference is that instead of providing a generic interface like `EntityManager` that's capable of performing persistence operations for any entity class, Jakarta Data requires that each interaction with the database goes via a user-written method specific to just one entity type. The method is marked with annotations allowing Hibernate to fill in the method implementation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NathanQingyangXu this sentence is correct! English has a subjunctive mood just like Spanish does. Sure, plenty of English speakers don't use it in spoken English, but it's more correct in written English, and I do use it because I guess I read too much. Here's what ChatGPT says about that sentence:
If you ask ChatGPT more about the subjunctive mood in English, I'm sure it will explain it to you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FTR this comes from the same reason you say "if I were ten feet tall" instead of "if I was ten feet tall". Many English speakers will use "was" here, which isn't incorrect, but "were" is more elegant. |
||
|
||
For example, whereas Jakarta Persistence defines the methods `find()` and `persist()` of `EntityManager`, in Jakarta Data the application programmer is required to write an interface like the following: | ||
|
||
|
@@ -352,7 +352,7 @@ This is our first glimpse of the advantages of using Jakarta Data repositories w | |
==== | ||
|
||
If there is no `Book` with the given `isbn` in the database, the method throws `EmptyResultException`. | ||
There's two ways around this if that's not what we want: | ||
There are two ways around this if that's not what we want: | ||
|
||
- declare the method to return `Optional`, or | ||
- annotate the method `@jakarta.annotation.Nullable`. | ||
|
@@ -399,7 +399,7 @@ Furthermore, if the parameter type is a list or array of the entity field type, | |
List<Book> books(String[] ibsn); | ||
---- | ||
|
||
Or course, an automatic query method might have multiple parameters. | ||
Of course, an automatic query method might have multiple parameters. | ||
|
||
[source,java] | ||
---- | ||
|
@@ -462,7 +462,7 @@ List<Book> booksByTitle(String pattern); | |
You might notice that: | ||
|
||
- The `from` clause is not required in JDQL, and is inferred from the return type of the repository method. | ||
- Since Jakarta Persistence 3.2, neither the `select` cause nor entity aliases (identification variables) are required in JPQL, finally standardizing a very old feature of HQL. | ||
- Since Jakarta Persistence 3.2, neither the `select` clause nor entity aliases (identification variables) are required in JPQL, finally standardizing a very old feature of HQL. | ||
|
||
This allows simple queries to be written in a very compact form. | ||
|
||
|
@@ -493,7 +493,7 @@ The JPQL specification provides the `select new` construct for this. | |
|
||
[source,java] | ||
---- | ||
@Query("select new AuthorBookRecord(b.isbn, a.ssn, a.name, b.title " + | ||
@Query("select new AuthorBookRecord(b.isbn, a.ssn, a.name, b.title) " + | ||
"from Author a join books b " + | ||
"where title like :pattern") | ||
List<AuthorBookSummary> summariesForTitle(@Pattern String pattern); | ||
|
@@ -509,7 +509,7 @@ Since this is quite verbose, Hibernate doesn't require the use of `select new`, | |
@Query("select isbn, ssn, name, title " + | ||
"from Author join books " + | ||
"where title like :pattern") | ||
List<AuthorBookSummary> summariesForTitle(@Pattern String pattern); | ||
List<AuthorBookSummary> summariesForTitle(String pattern); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems |
||
---- | ||
==== | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I'm letting you change these because in principle (to a linguistic prescriptivist) "there's three ways" is grammatically "incorrect" in written English. But note that "there's many things" is something that's incredibly common in informal English and this phrase sounds completely correct to a native speaker. I would never ever notice this "mistake" in either written or spoken English.