Commit Graph

367 Commits

Author SHA1 Message Date
Sam Brannen cfb1ed1009 Clean up warnings and delete dead code 2018-08-12 15:55:11 +02:00
Juergen Hoeller e64c6dfa3d MergedBeanDefinitionPostProcessors clear internal caches on bean reset
Issue: SPR-17126
2018-08-06 15:41:35 +02:00
Juergen Hoeller c46dacc209 Support for deferred access to StoredProcedureQuery output parameters
Issue: SPR-17115
2018-08-02 14:30:55 +02:00
Juergen Hoeller 9a43d2ec20 Revised log levels: less WARN and INFO, fine-tuned DEBUG vs TRACE
Issue: SPR-16946
2018-07-20 15:05:16 +02:00
Juergen Hoeller 9c08a482d1 Prefer ArrayList/ArrayDeque over LinkedList for multi-element holders
LinkedList remains in place where a List is likely to remain empty or single-element (in order to avoid unused capacity).

Issue: SPR-17037
2018-07-18 22:17:42 +02:00
Juergen Hoeller 93d91219fd Support for "cacheRegionFactory" injection with Hibernate 5
Issue: SPR-17043
2018-07-16 13:03:46 +02:00
Juergen Hoeller a80c5121fe Polishing 2018-07-09 15:53:44 +02:00
Juergen Hoeller d9e8d3bbe1 Custom "jdbcExceptionTranslator" on HibernateJpaDialect
Also available on LocalSessionFactoryBean through HibernateExceptionTranslator, as with our former Hibernate 3 support.

Issue: SPR-17015
2018-07-09 15:52:36 +02:00
Juergen Hoeller d2eb4d2671 SpringBeanContainer falls back to Hibernate's default producer
Issue: SPR-17010
2018-07-05 17:54:07 +02:00
Juergen Hoeller 620e83c35d SpringBeanContainer is public for custom JPA configuration purposes
Issue: SPR-16305
2018-07-05 16:48:35 +02:00
Juergen Hoeller 010ba33d03 Propagate read-only status through setDefaultReadOnly(true) for JPA
This involves a new ResourceTransactionDefinition variant that JpaTransactionManager indicates a transaction-local EntityManager on. HibernateJpaDialect uses this indicator for hard read-only behavior.

Issue: SPR-16956
2018-07-05 13:53:35 +02:00
Juergen Hoeller 63d6215247 Polishing 2018-07-04 19:23:27 +02:00
Juergen Hoeller c0d4cb55c7 LocalSessionFactoryBuilder provides Hibernate 5.3 BeanContainer support
LocalSessionFactoryBean automatically registers its containing BeanFactory as a BeanContainer when Hibernate 5.3 or higher is on the classpath.

Issue: SPR-16305
2018-07-04 19:23:19 +02:00
Juergen Hoeller 5dc8b5de6d Polishing 2018-07-04 15:07:17 +02:00
Juergen Hoeller 094c9b8bd2 LocalSessionFactoryBean and HibernateTransactionManager for JPA setup
SessionHolder extends EntityManagerHolder now, allowing for @PersistenceContext and co to interact with HibernateTransactionManager's thread-bound transactions, and SpringSessionContext is capable of interacting with JpaTransactionManager by detecting a plain EntityManagerHolder as well.

Issue: SPR-17002
2018-07-04 15:07:09 +02:00
Juergen Hoeller d22d408261 Propagate read-only status through Session.setDefaultReadOnly(true)
Issue: SPR-16956
2018-07-03 22:22:19 +02:00
Juergen Hoeller 40efcc933c Polishing 2018-06-28 14:51:33 +02:00
Juergen Hoeller b6d95567e8 Explicit support for Hibernate Integrators on LocalSessionFactoryBean
Issue: SPR-16828
2018-06-28 14:15:16 +02:00
Juergen Hoeller 81cb740e0a New postProcessProperties variant on InstantiationAwareBeanPostProcessor
Allows for skipping the now-deprecated postProcessPropertyValues callback with its expensive PropertyDescriptor retrieval requirement. RequiredAnnotationBeanPostProcessor (which is dependent on postProcessPropertyValues) and the @Required annotation itself are also deprecated now: in favor of constructor injection (or afterPropertiesSet).

Issue: SPR-16918
2018-06-28 14:15:16 +02:00
Phillip Webb 5cedd0d5d4 Consistently use tabs rather than spaces
Update code that has accidentally used spaces instead of tabs.
Also remove all trailing whitespace.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 0b53c1096a Always use 'this.' when accessing fields
Ensure that `this.` is used consistently when accessing class
fields.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb eeebd51f57 Use consistent class design
Update all classes so that inner classes are always last. Also
ensure that utility classes are always final and have a private
constructor and make exceptions final whenever possible.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb 866e9d702e Use consistent block style
Update all code to use a consistent block style.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Phillip Webb e0480f75ac Fix javadoc checkstyle issues
Fix checkstyle violations for javadoc.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Juergen Hoeller 25559b9e44 Polishing 2018-06-06 21:31:24 +02:00
Juergen Hoeller 3c8c99664f Query termination for JPA 2.1 StoredProcedureQuery.execute() method
Issue: SPR-16826
2018-05-16 00:44:52 +02:00
Juergen Hoeller 504e2768de Add SAP HANA to common JPA database platforms
Issue: SPR-16460
2018-05-05 20:38:10 +02:00
Juergen Hoeller ff53d78e96 Remove bogus DataSource test from JpaTransactionManagerTests 2018-04-10 00:40:51 +02:00
Juergen Hoeller 139dc1d373 Polishing (collapsed if checks, consistent downcasts, refined javadoc) 2018-03-08 18:11:57 +01:00
igor-suhorukov 0f7485b01d Polish: reorder the modifiers to comply with the Java Language Specification. 2018-03-08 17:57:47 +01:00
Juergen Hoeller eb9c43dcbc Reliably expose nested cause exception message for PersistenceException
Issue: SPR-16559
2018-03-06 23:06:14 +01:00
Juergen Hoeller cec7204fca Polishing 2018-03-02 13:53:17 +01:00
Juergen Hoeller cd4f0935c5 Revised deprecation markers 2018-03-01 23:43:06 +01:00
igor-suhorukov 83300c4b27 Polish: follow naming convention 2018-03-01 00:22:29 +01:00
Juergen Hoeller 578c078082 Polishing 2018-02-22 15:14:20 +01:00
Juergen Hoeller a5cbf5fe24 Consistent use of Collection.toArray with zero-sized array argument
Includes consistent use of ClassUtils.toClassArray (as non-null variant)

Issue: SPR-16523
2018-02-22 11:29:46 +01:00
Juergen Hoeller 3b810f3544 Consistent Class array vs vararg declarations (and related polishing) 2018-02-14 14:44:00 +01:00
Juergen Hoeller 39201adca4 Consistent handling of InterruptedException
Issue: SPR-16479
2018-02-10 13:03:33 +01:00
Juergen Hoeller e1fa65a37c Notes about HibernateJpaVendorAdapter settings vs native Hibernate rules
Issue: SPR-16428
2018-01-29 18:40:18 +01:00
Juergen Hoeller 4e194c3fbe Deprecate outdated HibernateTemplate operations in favor of lambdas
Issue: SPR-16426
2018-01-29 18:40:08 +01:00
Juergen Hoeller 9d0e62ef68 Javadoc format and related polishing 2018-01-22 11:43:21 +01:00
Juergen Hoeller 0270808b3c Upgrade to EclipseLink 2.7.1 2018-01-16 14:39:14 +01:00
Timo Meinen 823a16ce17 Log SQL parameters in EclipseLink when using showSql
As of EclipseLink 2.4.0 - Juno this is not sufficient to log
SQL parameter binding. Additionally,
eclipselink.logging.parameters must be enabled.

Issue: SPR-16383
2018-01-16 14:20:49 +01:00
Juergen Hoeller b6191f6057 Direct reference to JPA 2.1 SynchronizationType enum
Issue: SPR-13481
2018-01-07 23:30:05 +01:00
Juergen Hoeller e2018e6b72 HibernateJpaVendorAdapter sets connection release mode ON_CLOSE in non-PersistenceUnitInfo bootstrap scenario
Issue: SPR-16162
2017-11-11 18:43:43 +01:00
Juergen Hoeller a80fd9994a HibernateJpaVendorAdapter preserves connection release mode for JTA
Issue: SPR-16162
2017-11-10 20:21:03 +01:00
Juergen Hoeller 66a6fdacca Deprecate HibernateJpaSessionFactoryBean (against Hibernate 5.2)
Issue: SPR-16016
2017-10-04 12:29:16 +02:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

1) It adds a new Spring @NonNull annotation which allows to apply
@NonNullApi semantic on a specific element, like @Nullable does.
Combined with @Nullable, it allows partial null-safety support when
package granularity is too broad.

2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order
to be used on generic type arguments (SPR-15942).

3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore
since it is not supported yet (applicability for such use case is
controversial and need to be discussed).

4) @NonNullApi does not apply to ElementType.FIELD anymore since in a
lot of use cases (private, protected) it is not part for the public API
+ its usage should remain opt-in. A dedicated @NonNullFields annotation
has been added in order to set fields default to non-nullable.

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Juergen Hoeller 9fc4fb10b0 Nullability fine-tuning around bean properties
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 11:43:58 +02:00
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Juergen Hoeller c292a89b24 Http(Async)Client not actually nullable, plus MethodInterceptor nullability
Issue: SPR-15720
2017-07-19 00:15:37 +02:00
Juergen Hoeller cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Rossen Stoyanchev 5b8f7f503f Deprecate adapter classes for async interceptors 2017-06-26 15:34:51 -04:00
Violeta Georgieva e0678ba583 Add onError callback to DeferredResult
Issue: SPR-15614
2017-06-26 14:12:56 -04:00
diguage 1ef5f61ab2 Refactor iterator of Map with Java8's Map.forEach
See gh-1459
2017-06-13 16:06:20 +02:00
Stephane Nicoll 58242f2249 Polish 2017-06-13 10:13:14 +02:00
Stephane Nicoll fc64b8040f Polish "Replace relevant code with lambda"
Closes gh-1454
2017-06-13 09:42:20 +02:00
diguage 4b1478d830 Replace relevant code with lambda
See gh-1454
2017-06-13 08:55:38 +02:00
Juergen Hoeller e2e0410570 Method-level javadoc on XmlReaderContext etc 2017-06-11 12:03:05 +02:00
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Sebastien Deleuze 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
Juergen Hoeller 6fcf3a104f SharedEntityManagerCreator detects JPA 2.2's getResultStream method as query-terminating
This commit also changes "hibval5Version" to the more general "hibvalVersion" build variable, and includes dependency updates to Caffeine 2.5.1 and JRuby 9.1.9.

Issue: SPR-13482
2017-05-25 13:16:51 +02:00
Juergen Hoeller b2a6a572d3 Drop outdated DeferredQueryInvocationHandler.finalize() implementation
Issue: SPR-15363
2017-03-24 11:07:14 +01:00
Juergen Hoeller e892e02f41 Polishing 2017-03-21 17:44:47 +01:00
Juergen Hoeller 0f51ff5ebc Reset global rollback-only status when rolling back to savepoint
Issue: SPR-6568
2017-02-17 23:40:44 +01:00
Juergen Hoeller 07dd61eabd Drop NativeJdbcExtractor mechanism in favor of JDBC 4 unwrap
Issue: SPR-14670
2017-02-15 18:04:08 +01:00
Juergen Hoeller acf511ac0e Polishing 2017-02-02 20:11:06 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Juergen Hoeller e19dff179e Polishing 2017-01-12 21:18:01 +01:00
Sam Brannen 9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Juergen Hoeller 6d1cae2f57 Avoid proxy replacement for generic return type signatures
Issue: SPR-15010
2016-12-14 22:00:41 +01:00
Juergen Hoeller 2f80b8485a JPA/Hibernate docs: transaction management, JTA setup
Issue: SPR-14957
2016-12-08 18:24:12 +01:00
Juergen Hoeller b3cd1ad7f1 Refined throwing of BeanCreationExceptions (and reflection exceptions)
Issue: SPR-14883
2016-11-07 19:03:18 +01:00
Juergen Hoeller 5912d6f52a LocalSessionFactoryBean clears default MetadataSources on reinitialization
Issue: SPR-14815
2016-10-28 15:35:04 +02:00
Philippe Marschall ae5b0c6fb5 Replace J2EE with Java EE
String with version 5 the name of Java Platform, Enterprise Edition
changed from J2EE to Java EE. However a lot of the documentation still
uses the term J2EE.

This commit includes the following changes:

 * replace J2EE with Java EE where appropriate

This is not a blind search and replace. The following occurrences
remain unchanged:

 * references to old J2EE releases, most notably 1.3 and 1.4.
 * references to "Expert One-On-One J2EE Design and Development"
 * references to "Core J2EE patterns"
 * XML namespaces
 * package names

Issue: SPR-14811
See gh-1206
2016-10-15 11:49:00 +03:00
Juergen Hoeller bb7d20762c DefaultPersistenceUnitManager extracts jar file from default persistence unit root URL
Issue: SPR-14749
2016-09-26 15:15:45 +02:00
Juergen Hoeller 34ab818dfa HibernateExceptionTranslator avoids JPA IllegalState/ArgumentException translation
Issue: SPR-14681
2016-09-13 21:46:02 +02:00
Juergen Hoeller d631b4cca9 HibernateTemplate reflectively calls getNamedQuery (for runtime compatibility with Hibernate 5.0/5.1 vs 5.2)
Issue: SPR-14676
2016-09-10 12:38:04 +02:00
Stephane Nicoll dcade06fa0 Support for candidate components index
This commit adds a "spring-context-indexer" module that can be added to
any project in order to generate an index of candidate components defined
in the project.

`CandidateComponentsIndexer` is a standard annotation processor that
looks for source files with target annotations (typically `@Component`)
and references them in a `META-INF/spring.components` generated file.

Each entry in the index is the fully qualified name of a candidate
component and the comma-separated list of stereotypes that apply to that
candidate. A typical example of a stereotype is `@Component`. If a
project has a `com.example.FooService` annotated with `@Component` the
following `META-INF/spring.components` file is generated at compile time:

```
com.example.FooService=org.springframework.stereotype.Component
```

A new `@Indexed` annotation can be added on any annotation to instructs
the scanner to include a source file that contains that annotation. For
instance, `@Component` is meta-annotated with `@Indexed` now and adding
`@Indexed` to more annotation types will transparently improve the index
with additional information. This also works for interaces or parent
classes: adding `@Indexed` on a `Repository` base interface means that
the indexed can be queried for its implementation by using the fully
qualified name of the `Repository` interface.

The indexer also adds any class or interface that has a type-level
annotation from the `javax` package. This includes obviously JPA
(`@Entity` and related) but also CDI (`@Named`, `@ManagedBean`) and
servlet annotations (i.e. `@WebFilter`). These are meant to handle
cases where a component needs to identify candidates and use classpath
scanning currently.

If a `package-info.java` file exists, the package is registered using
a "package-info" stereotype.

Such files can later be reused by the `ApplicationContext` to avoid
using component scan. A global `CandidateComponentsIndex` can be easily
loaded from the current classpath using `CandidateComponentsIndexLoader`.

The core framework uses such infrastructure in two areas: to retrieve
the candidate `@Component`s and to build a default `PersistenceUnitInfo`.
Rather than scanning the classpath and using ASM to identify candidates,
the index is used if present.

As long as the include filters refer to an annotation that is directly
annotated with `@Indexed` or an assignable type that is directly
annotated with `@Indexed`, the index can be used since a dedicated entry
wil be present for that type. If any other unsupported include filter is
specified, we fallback on classpath scanning.

In case the index is incomplete or cannot be used, The
`spring.index.ignore` system property can be set to `true` or,
alternatively, in a "spring.properties" at the root of the classpath.

Issue: SPR-11890
2016-09-01 15:30:47 +02:00
Juergen Hoeller 5ee65cd4b1 Updated to JPA 2.1 requirement 2016-08-18 10:17:01 +02:00
Juergen Hoeller f1ab37cd01 Renamed setDefaultPersistenceUnitRootLocation to setPersistenceUnitRootLocation 2016-08-17 22:12:47 +02:00
Stephane Nicoll 1cad98dd31 Add setter for defaultPersistenceUnitRootLocation
This commit adds a setter for the default persistence unit's
defaultPersistenceUnitRootLocation attribute.
2016-08-17 17:40:58 +02:00
Juergen Hoeller 8b5d3559f5 Avoid stack overflow in case of chained factory-bean references to FactoryBean class
Issue: SPR-14551
2016-08-11 22:56:14 +02:00
Juergen Hoeller 6157fad91f PersistenceAnnotationBeanPostProcessor obtains default EntityManagerFactory via getBean(Class) algorithm
Issue: SPR-7549
2016-08-11 22:42:06 +02:00
Juergen Hoeller 36143692ac Consistent use of AvailableSettings instead of Environment
Issue: SPR-14548
2016-08-08 14:48:05 +02:00
Juergen Hoeller fad931d764 Consistent default connection release mode with Hibernate 5.1
Issue: SPR-14548
2016-08-04 03:07:14 +02:00
Sam Brannen 7ff9f0a8e9 Clean up warnings in spring-orm 2016-07-26 14:02:33 +02:00
Juergen Hoeller 195467083c Drop JpaSystemException(PersistenceException) constructor to avoid ambiguity in HibernateJpaVendorAdapter
Hibernate 5.2's HibernateException extends PersistenceException, leading to a different constructor compiled into the bytecode, breaking compatibility with Hibernate 5.0 at runtime.

Issue: SPR-13827
2016-07-26 01:23:39 +02:00
Sam Brannen beb45aac69 Suppress deprecation warning in PersistenceInjectionTests 2016-07-23 17:20:09 +02:00
Juergen Hoeller aae4874b85 Revised spring-orm test suite (no AbstractJpaTests anymore)
Issue: SPR-13515
2016-07-19 17:50:57 +02:00
Juergen Hoeller 1670b4e154 Reliably pass CurrentTenantIdentifierResolver to SessionFactory
Issue: SPR-14476
2016-07-19 17:25:07 +02:00
Juergen Hoeller adbc592f50 Unwrap JPA PersistenceException on flush failure (for Hibernate 5.2)
Issue: SPR-14457
2016-07-13 22:30:52 +02:00
Juergen Hoeller ddb4117233 HibernateExceptionTranslator converts JPA exceptions as well (for Hibernate 5.2)
Issue: SPR-14455
2016-07-13 22:24:38 +02:00
Juergen Hoeller c43e7497c1 Fixed typo: "occured"->"occurred" 2016-07-08 15:12:16 +02:00
Juergen Hoeller a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00