Skip to content

Commit 0232739

Browse files
committed
Javadoc coverage of package metadata detection (supported for Hibernate, not needed for EclipseLink and OpenJPA)
Issue: SPR-10910
1 parent 1c91a52 commit 0232739

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

spring-orm-hibernate4/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateJpaPersistenceProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
* is an alternative for compatibility with earlier Hibernate versions (3.6-4.2).
3838
*
3939
* @author Juergen Hoeller
40+
* @author Joris Kuipers
4041
* @since 4.1
42+
* @see Configuration#addPackage
4143
*/
4244
class SpringHibernateJpaPersistenceProvider extends HibernatePersistenceProvider {
4345

spring-orm/src/main/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBean.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ public void setPersistenceUnitName(String persistenceUnitName) {
149149
* <p>Default is none. Specify packages to search for autodetection of your entity
150150
* classes in the classpath. This is analogous to Spring's component-scan feature
151151
* ({@link org.springframework.context.annotation.ClassPathBeanDefinitionScanner}).
152+
* <p><p>Note: There may be limitations in comparison to regular JPA scanning.</b>
153+
* In particular, JPA providers may pick up annotated packages for provider-specific
154+
* annotations only when driven by {@code persistence.xml}. As of 4.1, Spring's
155+
* scan can detect annotated packages as well if supported by the given
156+
* {@link JpaVendorAdapter} (e.g. for Hibernate).
152157
* <p>If no explicit {@link #setMappingResources mapping resources} have been
153158
* specified in addition to these packages, Spring's setup looks for a default
154159
* {@code META-INF/orm.xml} file in the classpath, registering it as a mapping

spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ public void setDefaultPersistenceUnitName(String defaultPersistenceUnitName) {
215215
* may live next to regularly defined units originating from {@code persistence.xml}.
216216
* Its name is determined by {@link #setDefaultPersistenceUnitName}: by default,
217217
* it's simply "default".
218+
* <p><p>Note: There may be limitations in comparison to regular JPA scanning.</b>
219+
* In particular, JPA providers may pick up annotated packages for provider-specific
220+
* annotations only when driven by {@code persistence.xml}. As of 4.1, Spring's
221+
* scan can detect annotated packages as well if supported by the given
222+
* {@link org.springframework.orm.jpa.JpaVendorAdapter} (e.g. for Hibernate).
218223
* <p>If no explicit {@link #setMappingResources mapping resources} have been
219224
* specified in addition to these packages, this manager looks for a default
220225
* {@code META-INF/orm.xml} file in the classpath, registering it as a mapping

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/EclipseLinkJpaVendorAdapter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,11 +33,15 @@
3333
* Persistence Services (EclipseLink). Developed and tested against EclipseLink 2.4.
3434
*
3535
* <p>Exposes EclipseLink's persistence provider and EntityManager extension interface,
36-
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
36+
* and adapts {@link AbstractJpaVendorAdapter}'s common configuration settings.
37+
* No support for the detection of annotated packages (through
38+
* {@link org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo#getManagedPackages()})
39+
* since EclipseLink doesn't use package-level metadata.
3740
*
3841
* @author Juergen Hoeller
3942
* @author Thomas Risberg
4043
* @since 2.5.2
44+
* @see EclipseLinkJpaDialect
4145
* @see org.eclipse.persistence.jpa.PersistenceProvider
4246
* @see org.eclipse.persistence.jpa.JpaEntityManager
4347
*/

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@
4040
* Hibernate EntityManager. Developed and tested against Hibernate 3.6 and 4.2/4.3.
4141
*
4242
* <p>Exposes Hibernate's persistence provider and EntityManager extension interface,
43-
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
43+
* and adapts {@link AbstractJpaVendorAdapter}'s common configuration settings.
44+
* Also supports the detection of annotated packages (through
45+
* {@link org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo#getManagedPackages()}),
46+
* e.g. containing Hibernate {@link org.hibernate.annotations.FilterDef} annotations,
47+
* along with Spring-driven entity scanning which requires no {@code persistence.xml}
48+
* ({@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setPackagesToScan}).
4449
*
4550
* <p>Note that the package location of Hibernate's JPA support changed from 4.2 to 4.3:
4651
* from {@code org.hibernate.ejb.HibernateEntityManager(Factory)} to
@@ -51,6 +56,9 @@
5156
* @author Juergen Hoeller
5257
* @author Rod Johnson
5358
* @since 2.0
59+
* @see HibernateJpaDialect
60+
* @see org.hibernate.ejb.HibernatePersistence
61+
* @see org.hibernate.ejb.HibernateEntityManager
5462
*/
5563
public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
5664

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/OpenJpaVendorAdapter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,11 +33,15 @@
3333
* Developed and tested against OpenJPA 2.2.
3434
*
3535
* <p>Exposes OpenJPA's persistence provider and EntityManager extension interface,
36-
* and supports {@link AbstractJpaVendorAdapter}'s common configuration settings.
36+
* and adapts {@link AbstractJpaVendorAdapter}'s common configuration settings.
37+
* No support for the detection of annotated packages (through
38+
* {@link org.springframework.orm.jpa.persistenceunit.SmartPersistenceUnitInfo#getManagedPackages()})
39+
* since OpenJPA doesn't use package-level metadata.
3740
*
3841
* @author Costin Leau
3942
* @author Juergen Hoeller
4043
* @since 2.0
44+
* @see OpenJpaDialect
4145
* @see org.apache.openjpa.persistence.PersistenceProviderImpl
4246
* @see org.apache.openjpa.persistence.OpenJPAEntityManager
4347
*/

spring-orm/src/main/java/org/springframework/orm/jpa/vendor/SpringHibernateEjbPersistenceProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
* <p>Compatible with Hibernate 3.6 as well as 4.0-4.2.
3434
*
3535
* @author Juergen Hoeller
36+
* @author Joris Kuipers
3637
* @since 4.1
38+
* @see Ejb3Configuration#addPackage
3739
*/
3840
class SpringHibernateEjbPersistenceProvider extends HibernatePersistence {
3941

0 commit comments

Comments
 (0)