-
Notifications
You must be signed in to change notification settings - Fork 38.5k
orm.xml should be recognized by default if using JPA [SPR-11234] #15859
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
Comments
Juergen Hoeller commented Have a look at #13086: You can define orm.xml-like resources as "mappingResources" on LocalContainerEntityManagerFactoryBean, with any choice of file name and location. Unfortunately, a JPA provider detects orm.xml based on the local of persistence.xml files, with Spring having no direct influence there. So if there is no persistence.xml, there is no default orm.xml according to the persistence provider. However, we can expose <mapping-file> like entries through PersistenceUnitInfo, and this is exactly what "mappingResources" does. Juergen |
Hantsy Bai commented I understand your meanings. But Spring can work without a persistence.xml file, it is unreasonable it can not recognize the default orm.xml. It is easy to add the orm.xml to mappingResources in LocalContainerEntityManagerFactoryBean by default if it is existed. |
Juergen Hoeller commented We've addressed this for 4.0.1 now, autodetecting a "META-INF/orm.xml" file in the classpath and using it for Spring's default persistence unit if it is not co-located with a "META-INF/persistence.xml" file (since in case of such co-location, we assume it is intended for use with that persistence.xml file only, like in standard JPA layout). Juergen |
Hantsy Bai commented I found the JPA standard way does not work now, in my case, persistence.xml and orm are existed in /META-INF folder. What I wanted is */META-INF/orm.xml *can be detected by Spring, with or without existence of */META-INF/persistence.xml *file. |
Cristi Vulpe commented I know this is an old issue, but here is my case: All is good, but the problem that I found is that the documentation is not very explicit about the fact that orm.xml will be by default considered. I found this from this post: http://stackoverflow.com/questions/32062828/spring-boot-load-orm-xml, experimented it and it seems to be working just fine. Is it possible to update the spring boot documentation and describe one paragraph on this? I think a description like the one below would be just fine (assuming technically accurate): cristi |
Hantsy Bai opened SPR-11234 and commented
I used Hibernate as JPA provider and registered a LocalContainerEntityManagerFactoryBean without a persistence.xml.
But when I tried to resgiter a global audit entity listener in orm.xml file, it did not work.
I have to create a empty persistence.xml to make it work.
I think Spring should load the orm.xml by default if JPA is enabled, both with persistence.xml and without persistence.xml.
The related codes is hosted on my github.com
https://github.com/hantsy/spring-sandbox/tree/master/data-audit
Affects: 3.2.6
Issue Links:
Referenced from: commits 4ae893e
0 votes, 5 watchers
The text was updated successfully, but these errors were encountered: