mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 10:46:10 +02:00
Add a jpaTm().query(...) convenience method (#1023)
* Add a jpaTm().query(...) convenience method This replaces the more ungainly jpaTm().getEntityManager().createQuery(...). Note that this is in JpaTransactionManager, not the parent TransactionManager, because this is not an operation that Datastore can support. Once we finish migrating away from Datastore this won't matter anyway because JpaTransactionManager will be merged into TransactionManager and then deleted. In the process of writing this PR I discovered several other methods available on the EntityManager that may merit their own convenience methods if we start using them enough. The more commonly used ones will be addressed in subsequent PRs. They are: jpaTm().getEntityManager().getMetamodel().entity(...).getName() jpaTm().getEntityManager().getCriteriaBuilder().createQuery(...) jpaTm().getEntityManager().createNativeQuery(...) jpaTm().getEntityManager().find(...) This PR also addresses some existing callsites that were calling getEntityManager() rather than using extant convenience methods, such as jpa().insert(...).
This commit is contained in:
parent
c827ea033a
commit
4ed23f6813
57 changed files with 166 additions and 177 deletions
|
@ -196,7 +196,7 @@ PRESUBMITS = {
|
|||
# - concatenation of literals: (\s*\+\s*"([^"]|\\")*")*
|
||||
# Line 3: , or the closing parenthesis, marking the end of the first
|
||||
# parameter
|
||||
r'.*\.create(Native)?Query\('
|
||||
r'.*\.(query|createQuery|createNativeQuery)\('
|
||||
r'(?!(\s*([A-Z_]+|"([^"]|\\")*"(\s*\+\s*"([^"]|\\")*")*)'
|
||||
r'(,|\s*\))))',
|
||||
"java",
|
||||
|
@ -206,6 +206,7 @@ PRESUBMITS = {
|
|||
# using Criteria
|
||||
"ForeignKeyIndex.java",
|
||||
"HistoryEntryDao.java",
|
||||
"JpaTransactionManager.java",
|
||||
"JpaTransactionManagerImpl.java",
|
||||
# CriteriaQueryBuilder is a false positive
|
||||
"CriteriaQueryBuilder.java",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue