Skip to content
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

Doc: MutablePersistenceUnitInfo.addManagedPackage() not triggering a package scan [SPR-12821] #17418

Closed
spring-projects-issues opened this issue Mar 16, 2015 · 3 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Mar 16, 2015

Filipe Leandro opened SPR-12821 and commented

When using the PersistenceUnitPostProcessor interface for dynamically injecting Entities and Named Queries in my EntityManagerFactory, I use the method MutablePersistenceUnitInfo.addManagedPackage() to add a package for the EntityManagerFactory scan for entities.

However these packages never get scanned.
If I use the method MutablePersistenceUnitInfo.addManagedClassName() and manually add all the classes in thoses packages it works with no problem.

I'm I doing something wrong?
I have tried using these persistenceProviders with the same end result:

  • org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider
  • org.hibernate.jpa.HibernatePersistenceProvider

Affects: 4.1.5

Referenced from: commits 98d00ea, 4f1d9fd

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 16, 2015

Juergen Hoeller commented

I'm afraid this is not the purpose of addManagedPackage: That method just adds the actual package declaration for annotation inspection, i.e. a package.java with annotations on it. The framework internally calls that method during subpackage scanning.

Package scanning itself is rather driven by setPackagesToScan on LocalContainerEntityManagerFactoryBean / DefaultPersistenceUnitManager and cannot get modified at the PersistenceUnitInfo level anymore (since it already happened before).

Juergen

Loading

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 17, 2015

Filipe Leandro commented

Thank you for your response.
Could the documentation be improved? There is no information in this subject and maybe other people might get confused as I did.

Loading

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 17, 2015

Juergen Hoeller commented

Good point, this should be made clear in the javadocs at least. Reopening this issue for that purpose.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants