You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add 'mappingLocations' to LocalContainerEntityManagerFactoryBean to scan any JPA mapping files (ORM.xml) in the classpath. [SPR-8440] #13086
Add 'mappingLocations' to LocalContainerEntityManagerFactoryBean for reading/scanning the JPA mapping files (ORM.xml) in the classpath. This will allow developers to write JPA queries and custom mappings in more modular approach. Developers can easily put the ORM.xml in the same package with the Entity class it relates to.
Oliver just added ClasspathScanningPersistenceUnitPostProcessor to solve this mapping files scanning issue(DATAJPA-122). I wonder if it is possible to include this feature permanently at LocalContainerEntityManagerFactoryBean.
I've added a "mappingResources" property to LocalContainerEntityManagerFactoryBean, pointing to orm.xml like files in the classpath. Note that those are not Spring location values but rather classpath resources, similar to the same-named property on the Hibernate LocalSessionFactoryBean. They will be merged into the default persistence unit, just like "packagesToScan" entity classes, and can also be combined with "packagesToScan".
JPA insists on those file names to be classpath-relative resources, so a URL-based approach won't work in a portable fashion. This is a problem with the Spring Data JPA approach, as far as I can see, since classpath scanning will return URL resources, not classpath-relative locations. This might work with some JPA providers but it won't be portable (to the best of my understanding).
So with LocalContainerEntityManagerFactoryBea, we expect "mappingResources" to be fully qualified classpath resources a la "META-INF/mappings.xml" or "com/mycompany/repository/mappings.xml". Enumerating them shouldn't be too hard in a typical application; as per the above, we do not support patterns there.
Thanks Juergen!! I am going to try it tonight. Thanks for explanation on the JPA specs (I wonder why they didn't follow Spring way of discovering resources which is more modular)
Having this mappingResources at LocalContainerEntityManagerFactoryBean is a great move. Hopefully, the merging feature in #11189 will remove the needs to configure the mapping files locations there.
Activity
spring-projects-issues commentedon Dec 5, 2011
Donny A. Wijaya commented
Hi Juergen,
Oliver just added ClasspathScanningPersistenceUnitPostProcessor to solve this mapping files scanning issue(DATAJPA-122). I wonder if it is possible to include this feature permanently at LocalContainerEntityManagerFactoryBean.
Thanks!!
spring-projects-issues commentedon Dec 6, 2011
Juergen Hoeller commented
I've added a "mappingResources" property to LocalContainerEntityManagerFactoryBean, pointing to orm.xml like files in the classpath. Note that those are not Spring location values but rather classpath resources, similar to the same-named property on the Hibernate LocalSessionFactoryBean. They will be merged into the default persistence unit, just like "packagesToScan" entity classes, and can also be combined with "packagesToScan".
JPA insists on those file names to be classpath-relative resources, so a URL-based approach won't work in a portable fashion. This is a problem with the Spring Data JPA approach, as far as I can see, since classpath scanning will return URL resources, not classpath-relative locations. This might work with some JPA providers but it won't be portable (to the best of my understanding).
So with LocalContainerEntityManagerFactoryBea, we expect "mappingResources" to be fully qualified classpath resources a la "META-INF/mappings.xml" or "com/mycompany/repository/mappings.xml". Enumerating them shouldn't be too hard in a typical application; as per the above, we do not support patterns there.
Juergen
spring-projects-issues commentedon Dec 7, 2011
Donny A. Wijaya commented
Thanks Juergen!! I am going to try it tonight. Thanks for explanation on the JPA specs (I wonder why they didn't follow Spring way of discovering resources which is more modular)
Having this mappingResources at LocalContainerEntityManagerFactoryBean is a great move. Hopefully, the merging feature in #11189 will remove the needs to configure the mapping files locations there.